将ints的矩阵写入.txt
我正在尝试将int
s的479x639矩阵写入.txt
文件。最好每行包括一个条目,然后包括,
,以便我可以在MATLAB上输入数据。我使用以下代码尝试将原始数据写入.txt
:
FILE *f = fopen("output.txt", "w");
fwrite(output, sizeof(int), 479*639, f);
fclose(f);
我所得到的只是带有损坏数据的txt
。该程序的其余部分运行顺利。有什么建议吗?
I'm trying to write a 479x639 matrix of int
s to a .txt
file. Preferably each line will include one entry followed by a ,
, so that I can input the data on MATLAB. I used the following code to try and write the raw data to a .txt
:
FILE *f = fopen("output.txt", "w");
fwrite(output, sizeof(int), 479*639, f);
fclose(f);
All I get is a txt
with corrupted data. The rest of the program runs smoothly. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试一下,告诉我它是否有效
Try this out and tell me if it works