win32 讀取文字檔案,並進行字串分割和儲存

2022-08-17 16:00:18 字數 472 閱讀 4481

//分割字元

char *p;//p存放臨時行指標 q存放臨時每一行的列指標

char *hang[100]=;//儲存第一行

char *lie[300]=;//儲存一行中的每一項

p = strtok(buf,"\n-");//是已經在檔案中讀取的內容

int m=0;

while(p)

}

原型:extern char *strtok(char *s, char *delim);

用法:#include 

功能:分解字串為一組標記串。s為要分解的字串,delim為分隔符字串。

說明:首次呼叫時,s必須指向要分解的字串,隨後呼叫要把s設成null。

strtok在s中查詢包含在delim中的字元並用null('\0')來替換,直到找遍整個字串。

返回指向下乙個標記串。當沒有標記串時則返回空字元null。

讀取文字檔案

void ctestdlg onreadinfo cfile filewrite1 testwrite1.txt cfile modecreate cfile modewrite cfile filewrite2 testwrite2.txt cfile modecreate cfile modew...

讀取文字檔案內容

讀取文字檔案內容 param filepathandname 帶有完整絕對路徑的檔名 param encoding 文字檔案開啟的編碼方式 return 返回文字檔案的內容 public string readtxt string filepathandname,string encoding th...

linux c getline讀取文字檔案

函式原型 istream getline istream is,string str,char delim istream getline istream is,string str 讀取檔案,第乙個按引數delim作為分隔符,第二個以 n 作為分隔符。問題產生 在windows,新建文字文件,輸入...