April 6th, 2003, 07:12 AM
not returning full value. only 1.
dear oh dear. this is a very simple one i think but i can't see why this is happening. i should probably have just waited until i stopped being silly but i'm going to ask anyway:
the last part of a function that's been called from main:
and this is a bit of main:
printf("si: %d\n", si);
doesn't matter what si holds (so long as it's not 0), f comes out to be 1. so if si holds say 30, f in main is 1. in main, why isn't f 30?
while (getline(line, MAXLINE) > 0)
if (f = strrindex(line, pattern) >= 0)
and this is the start of the function that's returning:
int strrindex(char *s, char *t)
Last edited by balance; April 6th, 2003 at 07:18 AM.
April 6th, 2003, 09:03 AM
it's the >= result that gets put in f, not the function result. should be with extra brackets:
if ((f = strrindex(line, pattern)) >= 0)