while (getchar() != '\n')
2016-04-16 16:41
267 查看
/*问题:while (getchar() != '\n')continue; 跳过一行的剩余字符时间:2016/4/16*/#include <stdio.h>void display(char ch, int height, int width);int main(void){int ch;int rows, cols;printf("enter a character and two integers:\n");while ((ch = getchar()) != '\n'){if (scanf_s("%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");}return 0;}void display(char ch, int height, int width){for (int row = 0; row < height; row++){for (int col = 0; col < width; col++)putchar(ch);putchar('\n');}}
相关文章推荐
- Map很多Key-Value对应是可以此来处理!
- ActionBar的高度
- 指针常量与常量指针
- 工具使用
- eclipse项目调试配置文件路径
- ndk 静态库使用集锦
- Java基础(1)
- python ---- 自己坑自己
- 线程的基本操作
- Redis笔记_6
- 【NOIP2015模拟11.3】装饰大楼
- Launcher3源码浅析(5.1)--LauncherModel
- Java的运算符--与(&)、非(~)、或(|)、异或(^)详解
- 右键添加 CMD 命令提示符
- 博客园博客兼容手机浏览
- 页面性能优化
- 算法导论 第22章 22.1-4
- 20160415
- Cocos2dx基础使用相关面试题
- Android实现简单的自定义ListView