Hi.
I want to read several words from stdin (save them in string) and then process this string.
The problem is that my code works for the first time but when i finish processing i cannot read a new string from stdin, it enters in an infinite loop, printing Request.
Code:
while(1) {
printf("\nRequest\n>");
if(fgets(string, sizeof(string), stdin)!=NULL) {
sscanf(string,"%s",comand);
type = validateComand(comand);
if(type == 0)
continue; /* invalid type */
ptr = &string[strlen(comand)+1];
if ((aux = strchr(string, '\n')) != NULL) /* Remove \n */
*aux = '\0'; process(ptr,type);
}
}
}