关于 scanf 和 getchar 的while循环问题

初学萌新 求指教 !!!
错误程序:
#include
void display(char cr, int lines, int width);//打印字符的函数
int main(void)
{
int ch; //待打印字符
int rows, cols; //行数 列数
printf("Enter a character and two integers :\n");

scanf(" %c", &ch);  

while (ch != '\n')
{
if(scanf("%d%d", &rows, &cols)!=2)
break;

    display(ch, rows, cols);

    printf("Enter another character and two integers :\n");
    printf("Enter a newline to quit .\n");

    while (getchar() != '\n')//跳过前面多余的的输入
        continue;

    scanf("%c", &ch);   /*遇到的问题???*/
    //这里如果输入 回车换行符 ch赋值为 \n  为什么程序不退出循环呢?
    //如果用getchar() 简化所有的scanf()输入换行符 就能退出; 
}
printf("Bye !");
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');
}
}
正确程序:
下面是改过的函数
#include
void display(char cr, int lines, int width);
int main(void)
{
int ch;//待打印字符
int rows, cols;//行数 列数

printf("Enter a character and two integers :\n");

while ((ch=getchar())  != '\n')                       //改
{
    if(scanf("%d%d", &rows, &cols)!=2)
        break;

    display(ch, rows, cols);
    while (getchar() != '\n')
        continue;
    printf("Enter another character and two integers :\n");
    printf("Enter a newline to quit .\n");

//输入换行符即可退出
}
printf("Bye !");
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');
}
}
初学萌新 求指教 !!!
感谢耐心看完 感谢

楼主后来有弄懂吗?同问!

while里面每次都运行了ch=getchar()

#include<stdio.h>
void display(char cr, int lines, int width);
int main(void)
{
    int ch;//待打印字符
    int rows, cols;//行数 列数
    printf("Enter a character and two integers :\n");
    ch = getchar();
    while (1)                       //之前你每次循环都getchar导致接收混乱了
    {
        if (scanf("%d%d", &rows, &cols) != 2)
            break;

        display(ch, rows, cols);
        while (getchar() == '\n')
            break;
        printf("Enter another character and two integers :\n");
        printf("Enter a newline to quit .\n");

        //输入换行符即可退出
    }
    printf("Bye !");
    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');
    }
}