I have to make a shell in C, what should be a simple task is giving me trouble. The following code prints out the text and continually inputs, but only does the printf once.
printf("(pid=%ld)%s$", (long int)pid,cwd);
fflush(stdout);
while((bytes_read=getline(&line,&len,fp))){}
This code immediately infinite loops doing nothing but printing. I can't get any input.
do{
printf("(pid=%ld)%s$", (long int)pid,cwd);
fflush(stdout);
}while((bytes_read=getline(&line,&len,fp)));
How can I continually accept input in C like console applications do? I'm not sure why the program is behaving like this.