char b;
while((b=getchar()) != '.' );
{
   printf("%c",b);       
}

If I had the following input in stdin abcd.

it should print a then b then c then d then detect the . and terminate although its simply printing a . instead of abcd

有帮助吗?

解决方案

Remove the semicolon at the end of while condition

其他提示

The semicolon at the end of the while loop makes it execute only once . It does not loop at all . Your program is simple a linear program with no looping .

Otherwise your program logic is fine .

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top