C语言,android stdioo

.    main()   {int y=10; 
while(y--);  
printf(”Y=%d\n”,y);  
}  程序执行后的输出结果是(
A)y=0   B)y=">
求详解关于C语言的(21)有以下程序   #include<stdio.h>.    main()   {int y=10; 
while(y--);  
printf(”Y=%d\n”,y);  
}  程序执行后的输出结果是(
A)y=0   B)y=_百度作业帮
求详解关于C语言的(21)有以下程序   #include<stdio.h>.    main()   {int y=10; 
while(y--);  
printf(”Y=%d\n”,y);  
}  程序执行后的输出结果是(
A)y=0   B)y=
求详解关于C语言的(21)有以下程序   #include<stdio.h>.    main()   {int y=10; 
while(y--);  
printf(”Y=%d\n”,y);  
}  程序执行后的输出结果是(
A)y=0   B)y= -1   C)y=1   D)while构成无限循环
A你可以试着在编译器中运行一下,当y=1时while(y--) 中y的条件就变成了(0)跳过while语句。C语言——stdio.h
int fgetc(FILE * stream); get
character from stream
返回流中的一个字符,并以int的类型返回,如果碰到文件的结尾,或者一个错误发生,函数返回EOF,同时相应的错误或eof指示器被设置,可以用ferror或者feof来检查发生一个错误,或者到达了文件的末尾
int getc(FILE * stream); get
功能和fgetc一样,只是getc用宏来实现,因此当传递参数时,不应该是一个表达式,以防止潜在的副作用
int getchar(void); get character
从标准输入中读取下一个字符,等价于getc函数中奖参数设置为标准输入。返回值跟fgetc,getc一样。
int putchar(int character); write
character to stdout
将字符输出到标准输出中,如果没有错误发生,返回相同的字符,如果错误发生,则返回EOF,同时错误指示器被设置。
char * fgets(char * str, int num,
FILE * stream); get string from stream
从流中读字符串,将读到的num-1个字符存放到str所指向的缓冲中。当碰到换行或者EOF时,读结束。但是换行被作为一个有效的字符被读进了缓冲,同时自动在末尾加上一个NULL。通常num等于缓冲的大小。无错误时,函数返回指向字符串的指针,如果有错误发生则返回null。可以用ferror或feof来检查是错误发生还是到达了文件结尾。
char * gets(char * str); get
string from stdin
从标准输入读字符并将其存放到str中,直到碰到换行\n或者EOF,但是换行符并不读入到str中,这跟fgets不同。而且gets不知道要读多少字符,要特别小心以防止buffer
int fputs(const char* str, FILE *
stream); write string to stream
将str所指向的字符串写入到流中,直到字符串中碰到一个null,最后的null不会被写入到流中。成功返回一个非负的整数,错误返回EOF
int puts(const char * str); write
string to stdout
将字符串写到标准输出中,并附加一个换行符\n,当第一次碰到字符串中的null时,拷贝停止,null不会被写入到stdout中。
功能跟fputs(str, stdout)类似,但是fputs不附加一个换行符。
int fputc(int character, FILE *
stream); write
将字符写入到流中,并移动指示器的位置。成功会返回写入的字符,负责返回EOF。
int putc(int character, FILE
*stream); write
功能跟fputc一样,只是putc用宏来实现。因此要防止潜在的错误发生;
int ungetc(int character, FILE *
stream); unget character from stream
将一个字符虚拟的放入到输入流中,位置是上次读字符的位置。文件指示器倒退到前一个位置,因此这个被虚拟放入的字符被下一次的读操作所读到。只所以称之为虚拟放入,是因为和这个流相关联的文件的内容不会有任何的变化,因此这个操作只影响到下一次的读操作。要虚拟放入的字符可以跟上一次读的字符相同或者不相同。可以多个字符被虚拟放入。
如果设置了eof,调用这个函数后会将eof清除。fseek,fsetpos,rewind的调用会丢弃放入到流中的虚拟字符。如果要放入的是eof,则操作会失败,输入流不会发生变化。
直接的输入和输出
size_t fread(void * ptr, size_t
size, size_t count, FILE * stream); read block of data from
read an array of count elements, each one witha size of bytes,
from the stream and stores them in the block of memory specified by
the positon indicator of the stream is advanced by the total
amount of bytes read.the total amount of bytes read if successful
is (size * count);返回值为读到的element数,如果跟count不相等,则返回错误。
size_t fwrite(count void * ptr,
size_t size, size_t count, FILE * stream); write block of data to
将内存中的数据写入到流中,返回值为写入的element数,如果不等于count则错误。
流中的位置指示
int fgetpos(FILE * stream, fpos_t
position); get current position in stream
得到流目前的指示器,并将其存放到position所指向的对象中,这个只供fsetpos函数使用。成功返回0,否则返回一个错误。
int fsetpos(FILE * stream, const
fpos_t pos); set position indicator of stream
改变文件指示器,eof被清除,同时ungetc函数的效果也被清除。on streams open for update(read
+ write), a call to fsetpos allows to switch between reading and
writing.成功返回0,否则返回非零值,同时设置全局的errno,可以用perro来翻译这个值。
int fseek(FILE * stream, long int
offset, int origin); repositon stream position
用offset和origin来共同设置指示器,会清除eof和ungetc函数的效果。在文本文件中使用offset,而不是0或者ftell函数的返回值时,在某些平台上会有一些格式的转换,导致不可预料的位置指示。offset表示number
of bytes。SEEK_SET SEEK_CUR SEEK_END
long int ftell(FILE * stream); get
current positon in stream
返回目前指示器的值,是个长整型。对于二进制文件,返回从开始到指示器的字节数,对于文本文件不能保证返回的值是正确的字节数,但是返回值仍然可以用在fseek的offset变量中。发生错误会返回-1L,同时设置全局变量errno,可以用perror来扑捉;
void rewind(FILE * stream);set
positon indicator to the beginning
等价于fseek(stream, 0L, SEEK_SET),除了rewind会清除错误指示器。
错误处理函数
void clearerr(FILE) ; clear error
reset both error and eof indicator of the
stream.通过调用rewind,fseek,fsetpos函数会重新设置指示器
int feof(FILE * stream); check
end-of-file indicator
检查是否eof被设置,也就是是否到达文件的末尾,如果是则返回非零值,否则返回0.如果eof被设置,则对stream的进一步操作会失败,除非使用rewind,fseek,fsetpos函数进行重新设置。
int ferror(FILE * stream); check
error indicator
检查是否有错误指示器被设置,如果是则返回非零值,否则返回0.
void perror(const char * str);
print error message
将全局变量errono的值翻译成字符串,并打印。
是个非整数,通常有函数调用错误,或者到文件尾时返回。
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。09-1609-1709-0908-02
10-0310-0310-0310-02
◇本站云标签您的举报已经提交成功,我们将尽快处理,谢谢!
include&stdio.h&
使用& &表示按照标准方式搜索要嵌入的文件,该文件位于c++系统目录下的include子目录下,一般包含系统提供的标准文件时采用这样的方式,使用\" \"表示首...
大家还关注
(window.slotbydup=window.slotbydup || []).push({
id: '2081942',
container: s,
size: '1000,60',
display: 'inlay-fix'

我要回帖

更多关于 include stdio.h 的文章

 

随机推荐