18/09/01 14:32:20.17 PENKT9BN.net
>>445
2chは長い行で書き込めないのよ
string all;
char* path = "./hello.csv";
int size = (int)FileRead_size( path ) ; // 1char = 1byte
char* buffer = new char[size];
int id = FileRead_open( path, false ) ;
FileRead_read( buffer, size, id) ;
all = buffer; // copy to string
delete[] buffer;
FileRead_close(id);
// allをcsvのrow(\r\n)とcol(,)でパースする。csv書式の不正チェックとか丁寧にやると長くなるので以下適当
string csv[ROW][COL];
string tmp = "";
int x = 0; int y = 0;
for(int i=0; i<all.length(); i++){
char c = all[i];
if(c == ',') {
csv[y][x] = tmp; tmp = ""; x++;
} else if (c == '\n') { // 本当は\r\nの2つで改行なんだけど
csv[y][x] = tmp; tmp = ""; x = 0; y++;
} else { tmp += c; }
}
csv[y][x] = tmp; // 最後の一個
文字列(string)から数値(intとか)に変えるときはatoiじゃなくてstrstreamだかを使うとよい