scanf
简单的输入函数
结构
extern int scanf (const char *__restrict __format, ...) __wur;
函数说明
简单理解就是从缓冲区格式化读取,接受[^A-Z]正则表达式
实例
int u, v, h, l;
printf("Please input two numbers:\n");
while (1){
if (scanf("%d哈哈哈哈%d", &u, &v) != 2){
while (getchar() != '\n');
printf("你的输入有问题请重新输入\n");
continue;
}
break;
}
备注
这个示例用以输入两个整数
Please input two numbers:
5哈哈哈6
H.C.F=1
Please input two numbers:
4 4
你的输入有问题请重新输入
pringf
简单的输出函数
结构
extern int printf (const char *__restrict __format, ...);
函数说明
这个函数是格式化输出,类似canf
见scanf