c 語言讀取本地檔案

2021-10-07 15:46:11 字數 550 閱讀 6304

#includeint readfile(char *buff)

//fscanf 遇到第乙個空格和換行符時候 會停止讀取

fscanf(fp, "%s", buff);

printf("1: %s\n", buff );

//函式 fgets() 從 fp 所指向的輸入流中讀取 n - 1 個字元。它會把讀取的字串複製到緩衝區 buf,並在最後追加乙個 null 字元來終止字串。

fgets(buff, 255, (file*)fp);

printf("2: %s\n", buff );

fgets(buff, 255, (file*)fp);

printf("3: %s\n", buff );

char ch;

int n;

//fgetc 讀取第乙個字元 返回

n=fgetc((file*)fp) ;

printf("%d\n",n);

fclose(fp);

} int main()

C語言檔案讀取

若沒有該檔案,系統會自動建立該檔案。fp是檔案指標,char 型別。file是結構體,file 是結構體指標,typedef定義的file.開啟檔案操作時,就已經開啟了三個檔案。stdin,stdout,stderr file fopen const char path,const char mod...

讀取本地EXCEL檔案

data it excel like alsmex tabline occurs 0with header line.parameters fn like rlgrap filename memory id mo1.at selection screen onvalue request for fn...

python讀取本地檔案

fr open filename dataset line.strip split 分隔符 for line in fr.readline fr.close import numpy as np dataset np.genfromtxt filename,delimiter 分隔符 返回np.nd...