文件
在Excel中显示
在记事本和Notepad中显示
代码
#include <bits/stdc++.h>
using namespace std;
const char *input_file_name = "input.csv";
void read(){
FILE* pFILE = fopen(input_file_name, "r");
fseek(pFILE, 0, SEEK_END);
int file_size = ftell(pFILE);
char* buf = new char[file_size];
fseek(pFILE, 0, SEEK_SET);
fread(buf, 1, file_size, pFILE);
fclose(pFILE);
string str = "";
for(int i = 0; i < file_size; ++i){
if (buf[i] == '\n'){
printf("%s\n", str.c_str());
str = "";
continue;
}
str += buf[i];
}
delete[] buf;
return ;
}
int main(){
read();
return 0;
}