開啟檔案: http://goo.gl/OwS1n
分割字串: http://msdn.microsoft.com/zh-tw/library/ftsafwz3(v=vs.90).aspx
char filename[]="data.raw";
fstream fp;
char line_buffer[128];
char seps[] = ",";
char *token1 = NULL;
char *next_token1 = NULL;
//==read data start==
fp.open(filename, ios::in);//開啟檔案
if(!fp){//如果開啟檔案失敗,fp為0;成功,fp為非0
cout<<"Fail to open file: "<<filename<<endl;
}
//cout<<"File Descriptor: "<<fp<<endl;
while(fp.getline(line_buffer, sizeof(line_buffer), '\n'))
{
//printf("%s\n",line);
j=0;
// use to split string
// reference: http://msdn.microsoft.com/zh-tw/library/ftsafwz3(v=vs.90).aspx
token1 = strtok_s( line_buffer, seps, &next_token1);
while (token1 != NULL)
{
data[i][j] = atof(token1);
printf ("i=%i j=%i %f\n",i,j,data[i][j]);
token1 = strtok_s( NULL, seps, &next_token1);
j++;
if (j==5) break;
}
i++;
}
fp.close();//關閉檔案
//==read data end==
原本用了另一個方法來分析字串(http://goo.gl/P9SZV), 但VC會出現安全性的Warning, 故採用MSDN的方法
data.raw內容:
0.97681,0.10723,0.64385,0.29556,1
0.67194,0.2418,0.83075,0.42741,1
0.20619,0.23321,0.81004,0.98691,1
0.51583,0.055814,0.92274,0.75797,1
0.70893,0.10836,0.33951,0.77058,1
0.55743,0.67804,0.061044,0.72689,1
0.15654,0.75584,0.01122,0.42598,-1
0.50462,0.15137,0.33878,0.41881,1
0.22657,0.59272,0.24103,0.46221,-1
0.49174,0.65115,0.24622,0.24796,-1
0.59512,0.26994,0.74692,0.32784,1
0.32439,0.37294,0.11623,0.94499,1
訂閱:
張貼留言 (Atom)
Python notes: Calculate delay time by WinDBG log
用WinDBG開Event Timestamps可以產生下面格式的log: Fri Sep 21 18:43:50.946 2018 (UTC + 8:00): @#$#^$@#$^ 以下python code用來找出兩個指定log中的時間差
-
今天照著mobile01的教學文把我的Incredible S預載的台灣大哥大無用軟體關閉了 在此做個筆記... 其實這支手機剛買來時就做過一樣的事了 但因年前HTC釋出了Android 2.3.5的更新, 使我已經ROOT的手機又再經過S-ON後復原 更新到Android 2....
-
這是上次去日本時遇到一個窘境時所找到的Windows7下的應用軟體 Connectify 儘管現在無線網路已經充斥在你我周遭, 但還是有些地方只有提供有線網路, 而沒有WIFI 像我去東京時下榻的飯店-- Sun Members Tokyo Shinjuku ...
-
最近買了房子, 身為勤儉持家的客家子弟怎麼可能去請室內設計師來呢 我要自己來! Google到這隻專門繪製室內格局圖的程式, 作者好像是個法國人, 有簡體中文的版本, 還是免費版的唷!
沒有留言:
張貼留言
Thanks for your message.