I have a linux box.
On this linux box, there is a program.
In this program, I have a loop like this:
int num=*"what num needs to be"*;
char proc[num];
int result;
while (1) {
result=scanf("%[^'&']%s",proc);
printf("And proc is: %s\n",proc);
printf("Result counter was: %i\n",result)
if (result == 0) break;
}
scanf("%[^'&'],%s",proc)
printf("post lop result is: %s", proc);
As you may have guessed, stdin contains data I need delineated by the '&' character.
As I'm hoping someone more skilled than me has guessed, the output looks something like:
And proc is: *first delineated section*
Result counter was: 1
And proc is: *first delineated section*
Result counter was: 0
post loop result is: *first delineated section*
I thought that scanf was supposed to consume the part of stdin it has already read. Why isn't it doing this?
Also, FYI: this is being run on a very cheap, slow server. Volume may or may not become more than slight. Efficiency is thus a plus, I'm open to however someone might suggest I do this....
Thanks!