求教 关于连续输入的问题
程序代码://showchar.c--按行列打印字符
#include<stdio.h>
void display(char cr , int lines , int width);//其中cu是打印的字符。lines是打印几行,width打印几列
int main(void)
{
int ch;
int rows , cols;
printf("Enter a character and two integers:\n");
while((ch=getchar())!='\n')//要打印的字符
{
scanf("%d %d",&rows , &cols);
display(ch , rows , cols);
while(getchar()!='\n')//不理解这个while语句。如果不加这个语句就不能实现连续的输入,程序只能执行一遍。为什么加上后就能连续输入了呢?
continue;
printf("Enter another character and two integers:\n");
printf("Enter a newlines to quit.\n");
}
printf("Bye.\n");
getchar();
return 0;
}
void display(char cr , int lines , int width)
{
int row , col;
for(row=1;row<=lines;row++)
{
for(col = 1; col <= width; col++)
{
putchar(cr);
}
putchar('\n');
}
}搞不明白 求解释。 C primer plus 第199页的程序











