资源描述:
《字符串+文件处理函数.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、C语言标准输入输出:待续printf格式输出到屏幕//把指定内存空间中内容格式输出到屏幕;fprintf格式输出到磁盘//scanf从屏幕格式输入//从stdin中格式读入到给定变量空间中fscanf从磁盘格式输入putchar字符输出到屏幕puts字符串输出到屏幕fputc字符输出到磁盘fputs字符串输出到磁盘getchar从屏幕得到一个字符//从stdin中读取一个字符,返回字符ASCII值gets从屏幕得到一个字符串//从stdin中读取字符串,返回内存空间位置fgetc从磁盘得到一个字符fgets从磁盘得到一个字符串fputc,fputs,putc,putchar,
2、puts-outputofcharactersandstringsSYNOPSIS#includeintfputc(intc,FILE*stream);intfputs(constchar*s,FILE*stream);intputc(intc,FILE*stream);intputchar(intc);intputs(constchar*s);DESCRIPTIONfputc()writesthecharacterc,casttoanunsignedchar,tostream.fputs()writesthestringstostream,withouti
3、tsterminatingnullbyte(' ').putc()isequivalenttofputc()exceptthatitmaybeimplementedasamacrowhichevaluatesstreammorethanonce.putchar(c);isequivalenttoputc(c,stdout).puts()writesthestringsandatrailingnewlinetostdout.RETURNVALUEfputc(),putc()andputchar()returnthecharacterwrittenasanunsignedcha
4、rcasttoanintorEOFonerror.puts()andfputs()returnanonnegativenumberonsuccess,orEOFonerror.fgetc,fgets,getc,getchar,gets,ungetc-inputofcharactersandstringsSYNOPSIS#includeintfgetc(FILE*stream);char*fgets(char*s,intsize,FILE*stream);intgetc(FILE*stream);intgetchar(void);char*gets(char*
5、s);intungetc(intc,FILE*stream);DESCRIPTIONfgetc()readsthenextcharacterfromstreamandreturnsitasanunsignedcharcasttoanint,orEOFonendoffileorerror.getc()isequivalenttofgetc()exceptthatitmaybeimplementedasamacrowhichevaluatesstreammorethanonce.getchar()isequivalenttogetc(stdin).gets()readsaline
6、fromstdinintothebufferpointedtobysuntileitheraterminatingnewlineorEOF,whichitreplaceswithanullbyte(' ').Nocheckforbufferoverrunisperformed(seeBUGSbelow).fgets()readsinatmostonelessthansizecharactersfromstreamandstoresthemintothebufferpointedtobys.ReadingstopsafteranEOForanewline.Ifanewline
7、isread,itisstoredintothebuffer.Aterminatingnullbyte(' ')isstoredafterthelastcharacterinthebuffer.ungetc()pushescbacktostream,castto(铸造)unsignedchar,whereitisavailableforsubsequentreadoperations.Pushed-backcharacterswillbereturnedinreverseorder;onlyonepu