正在加载图片...
C输入输出综述 6.1c输入输出综述 入输出操作是由函数来实现的 C语言函数库中有“标准输入输出函数 字符的输入与输出: getchar(、 putchar0 字符串的输入与输出 tso tso 格式输入与输出: scanf(、 printf 在使用C语言库函数时,要用预编译命令“# include”将有关的“头文件”包括到用户源文件 例如:使用标准输入输出库函数时,要用到“ stdio.h”文件,在源文件开头应有 # include< stdio.h>或# include“ stdio.h” (一)字符数据的输入输出 字符输出函数 语法: putchar(c) 语义:(向 stdout终端)输出一个字符 如:# include< stdio.h> maIn putchar(141’) putchar(‘a’); putchar(‘A’+32) putchar(‘n’); 2、字符输入函数 语法: getchar(),是一个无参函数 语义:(从 stdin终端上)输入一个字符 getchar包含在 stdio.h中,是 stdio.h中定义的宏;C 输入输出综述 6 . 1 C 输入输出综述 输入输出操作是由函数来实现的 C 语言函数库中有“标准输入输出函数” 字符的输入与输出:getchar()、putchar() 字符串的输入与输出: gets() 、puts() 格式输入与输出: scanf() 、printf() 在使用 C 语言库函数时,要用预编译命令“#include”将有关的“头文件”包括到用户源文件 中。 例如:使用标准输入输出库函数时,要用到“stdio.h”文件,在源文件开头应有: #include <stdio.h> 或 #include “stdio.h” (一)字符数据的输入输出 1、字符输出函数——putchar 语法:putchar(c) 语义:(向 stdout 终端)输出一个字符; 如:#include <stdio.h> main() { putchar(‘\141’); putchar(‘a’); putchar(‘A’+32); putchar(‘\n’); } 输 出:aaa 2、字符输入函数——getchar 语法:getchar ( ),是一个无参函数; 语义:(从 stdin 终端上) 输入一个字符; getchar 包含在 stdio.h 中,是 stdio.h 中定义的宏;
向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有