Hi friends,
Sorry to bother you again. Back to my old C problem... Given this
sequence of code:
/*-----------------------------do_nothing.c-----------------*/
char *s;
while(1){
s = malloc(10);
fgets(s, 10, stdin); /*stdin means console, right???*/
free(s);
}
/*----------------------------------------------------------*/
I've got this problem:
The first time the loop is executed, everything works ok, 's' is filled
with 9 characters plus '\0', but in the next loop, it doesn't read
anything from the console, but reads from the buffer(if the text
introduced the first time is > 10char). How can I make it read from the
console at each loop? I've tryied anything I know: fflush(stdin), s='\0'
at the beginning of each loop, even the malloc & free inside the loop,
like above...
Hope I'm not too boring... Thanks...
Have fun,
bogdan