|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
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: Code:
if(!x) {
printf("si: %d\n", si);
return si;
}
}
return -1;
}
and this is a bit of main: Code:
while (getline(line, MAXLINE) > 0)
if (f = strrindex(line, pattern) >= 0)
printf("%d\n", f);
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? and this is the start of the function that's returning: Code:
int strrindex(char *s, char *t)
{
...
Last edited by balance : April 6th, 2003 at 06:18 AM. |
|
#2
|
|||
|
|||
|
forget this.
it's the >= result that gets put in f, not the function result. should be with extra brackets: if ((f = strrindex(line, pattern)) >= 0) silly me. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > not returning full value. only 1. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|