无法在c++ Builder中写入.csv文件到StringGrid
Cannot write .csv file to StringGrid in C++ Builder
编辑:代码块编辑,现在唯一的问题是只有最后一行。csv文件是打印在StringGrid的每一行。原因是什么呢?提前谢谢。
基本上,项目的一个模块确实创建了一个输出文件,其中包含以逗号分隔格式的点坐标,如下所示:
#pt, x , y ,z
124,4500003.833,3499999.500,0
125,4500003.833,3499999.833,0
126,4500003.833,3500000.167,0
我要做的是用另一个模块读取.csv并将其放入StringGrid。
FILE *coord;
//some other things here
while (fgets(line,100,DosyaGiris)!=NULL) {
sscanf(line,"%d,%lf,%lf,%lf",&number,&x,&y,&z);
for (col = 0; col < 4; col++) {
StringGrid1->Cells[0][row] = IntToStr(number);
StringGrid1->Cells[1][row] = FloatToStr(x);
StringGrid1->Cells[2][row] = FloatToStr(y);
StringGrid1->Cells[3][row] = FloatToStr(z);
}
}
请建设性一点,祝你过得愉快。
由于不必要的for循环,它不能工作,现在它工作了
int i= 0;
while (fgets(line,100,DosyaGiris)!=NULL){
sscanf(line,"%d,%lf,%lf,%lf",&ID,&x,&y,&z);
StringGrid1->Cells[0][i+1] = IntToStr(ID);
StringGrid1->Cells[1][i+1] = FloatToStr(x);
StringGrid1->Cells[2][i+1] = FloatToStr(y);
StringGrid1->Cells[3][i+1] = FloatToStr(z);
i++;
}
相关文章:
- 正在将csv文件读取为双精度矢量
- 如何选择在 csv 文件中输出的位置
- 有没有办法在不使用 getline() 的情况下从.csv文件中读取?
- 无法读取C++中的 CSV 文件
- 流:CSV 文件中的换行符
- 如何正确格式化csv文件?
- 正在分析CSV文件-C++
- 如何获取组件和搜索 CSV 文件
- C++ 中的 CSV 文件管理(特别是设置标头和每个标头将分别具有的值)
- 无法逐行读取.csv文件
- 非常快速地阅读 CSV 文件
- 该程序将.csv文件中的一系列单词放入数组中,然后随机生成句子.但它不起作用
- CSV文件之间的差异,使用getline()产生不同的结果
- 将 CSV 文件中的双倍值C++到矢量中
- C++ 将 CSV 文件的列写入向量
- 使用getline读取.csv文件时出现问题
- CSV文件未从缓冲区获取数据
- 错误的值是使用c++从CSV文件数据写入数组
- 将csv文件加载到MySQL C++中
- 读取C++中的大型CSV文件(~4GB)