close
#include <fstream>
std::wstring wstrErrMsgDump = L"jiji\n1023=\nuhfizld\nhare\nrbgya\nazerreag\n123123123123\n45645645646\n";
char c[500];
memset (c,'\0',500);
std::fstream fp;
fp.open("test.csv", std::fstream::out);//開啟檔案的寫入功能 http://www.cplusplus.com/reference/fstream/fstream/open/
if(!fp){MessageBox(L"file open error");}
for ( int i = 0, c_index = 0; i < wstrErrMsgDump.length(); i++, c_index++ ) {
if ( wstrErrMsgDump[i] != L'\n' ) {
c[c_index] = wstrErrMsgDump[i];
} // end if
else if( wstrErrMsgDump[i] == L'\n' ) {
c[c_index] = ',';
fp << c;
memset (c,'\0',500);
c_index = -1;
} // end else if
} // end for
fp.close();
}
文章標籤
全站熱搜
留言列表