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();
}
arrow
arrow

    跪著讀 發表在 痞客邦 留言(0) 人氣()