stdio.h(standard input & output標準輸入輸出)
-fopen()
原型:file * fopen(const char * path,const char * mode);
返回值:若檔案成功開啟,則返回該流的檔案指標;若開啟失敗則返回null;
舉個栗子:
file *fp=fopen("d:\\test\\tes.txt","r");
file *fp=fopen("d:\\test\\tes.txt","r");
while(!feof(fp))
-fgets()
原型:char *fgets(char *buf, int bufsize, file *stream);
*buf: 字元型指標,指向用來儲存所得資料的位址。
bufsize: 整型資料,指明儲存資料的大小。
*stream: 檔案結構體指標,將要讀取的檔案流。
用於在stream中讀取資料,每次一行。
返回值:
成功,則返回第乙個引數buf;
在讀字元時遇到end-of-file,則eof指示器被設定,如果還沒讀入任何字元就遇到這種情況,則buf保持原來的內容,返回null;
如果發生讀入錯誤,error指示器被設定,返回null,buf的值可能被改變;
舉個栗子:
file *fp=fopen("d:\\test\\tes.txt","r");
while(!feof(fp))
fclose(fp);
-fputs()
原型:int fputs(char *str,file *stream);
向stream所指檔案中寫入字串str;
返回值:成功返回非負值,失敗返回eof;
-fscanf()
原型:int fscanf(file*stream,constchar*format,[argument…]);
遇到空格和換行時結束,注意空格時也結束
返回值:整型,成功返回讀入的引數的個數,失敗返回eof(-1);
-fclose()
原型:int fclose( file *fp )
-gets()
從stdin流中讀取字串,直至接受到換行符或eof時停止,並將讀取的結果存放在buffer指標所指向的字元陣列中。換行符不作為讀取串的內容,讀取的換行符被轉換為『\0』空字元,並由此來結束字串。
舉個栗子:
char name[80];
gets(name);
-futs()
輸出字串,直到』\0』;
舉個栗子:
char
string="it is an example";
puts(string);
-fflush()
原型:int fflush(file *stream)
其中stream是要沖洗的流
fflush(stdin);//清空輸入緩衝區
-ferror()
原型:int ferror(file *stream);
返回值:若正確,返回0;錯誤返回非零;
-fgetc()
原型:char fgetc(file *stream);
從檔案讀取乙個字元;
返回值:若正確,返回該字元;錯誤返回eof
-fputs()
原型:char fputc(char ch,file *stream);
向檔案中寫乙個字元ch;
返回值:正確,返回非負數;錯誤返回eof;
-fseek()
原型:int fseek(file *stream,long offset,int position);
把檔案指標移到離position offset的地方;
若offset >0,向前移動;反之向後移動;
返回值:成功返回0,失敗返回非零;
-ftell()
原型:long int ftell(file *stream);
返回值:指標距離檔案頭的偏離量;
-rewind()
原型: void rewind(file *stream);
重定位函式,用於把指標返回檔案頭;
-fread()
原型:int fread(void *buf,int size,int count,file *stream);
從檔案中以size為單位,共讀取count次,放到buf所指塊中;
返回值:正確返回count值,出錯返回小於count的值(或檔案到達底部);
-fwrite()
原型:int fwrite(void *buf,int size,int count,file *stream);
將buf所指塊中資料以size為單位分count次寫到所指檔案中去;
返回值:正確返回count值,出錯返回小於count的值;
conio.h(console input/output控制台輸入輸出)
stdlib.h(standard library標準庫標頭檔案,包含了c語言標準庫函式的定義)
string.h()(字串操作)
-strcat()
字串連線函式
舉個栗子:
char astring[20]="first",bstring[10]="second";
strcat(astring,bstring);//連線後的字串放在astring中
printf("%s",astring);//輸出firstsecond
-strcmp()
原型:extern int strcmp(const char *str1,const char *str2);
比較兩個字串
返回值:若str1==str2,則返回零;
若str1 > str2,則返回正數;
若str1 < str2,則返回負數。
-strcpy()
原型:char strcpy(char dest, const char *src);
把從src位址開始且含有null結束符的字串複製到以dest開始的位址空間
C語言中一些常用函式的使用記錄
brief 將整數轉換為字串 param str 字串 param intnum 要轉換的整數 10位數 retval none void int2str uint8 t str,int32 t intnum else 2021 04 02更新記錄 以下方式也可以實現。static char ito...
C語言學習的一些細節
一.變數的生命週期和作用域 生命週期 變數的存在時間 作用域 變數的作用範圍 變數的這兩個屬性決定了什麼時候以及在什麼地方可以使用此變數。需要注意的是 1.迴圈內部定義的變數,生命週期為迴圈開始到結束。int main printf d i 這條語句會報錯,使用了沒有定義的變數。return0 2....
tensorflow中一些常用函式記錄
簡單函式不給用例 函式原型 def moments x,axes,shift none,pylint disable unused argument name none,keep dims false 例子img tf.variable tf.random normal 2,3,4 keep dim...