关于“contiune”在C中的使用问题

本文介绍了一个使用C语言编写的程序,该程序通过读取用户输入的一个字符和两个整数,然后在控制台上打印出由该字符组成的指定行数和列数的矩形图案。此外,还探讨了一个关于continue语句行为的疑问,即为何在特定循环中使用continue后,程序并未跳过后续的printf语句。

#include<stdio.h>
void display(char cr, int lines, int width);
int main(void)
{
int ch;
int rows,cols;

printf("请输入一个字母和两个数字: \n");
while((ch = getchar()) != '\n')
{
	if ((scanf("%d %d", &rows, &cols)) != 2)
	    break;
	    
	display(ch, rows, cols);   
	**while (getchar() != '\n')
      {
      	 continue;// 想问一下如果执行了这个contiune 应该会跳过下面printf语句,为什么程序运行后没有跳过?
      }**  
   
	**printf("enter zhe new lines to quit \n");**     	
}
printf("Bye.\n");
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');
}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值