The logic you're using doesn't make a lot of sense. In your first loop there's no way out. The program will just sit there in the loop forever. What are you trying to accomplish? If you want to get a line of text from stdin try this:
Code:
#include <stdio.h>
#include <string.h>
int main(void)
{
int c;
do
{
c = getchar();
printf("%c", c);
} while(c != '\n');
return 0;
}
Quote:
$ ./getchar
This is a string
This is a string
$
|
The first "This is a string" is what I typed in. The second line shows up as soon as I hit ENTER. This is exactly the way the program is expected to work.