fprintf不打印新行 [英] fprintf not printing new line

查看:159
本文介绍了fprintf不打印新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用 fprintf()命令将[2 x N]大的数组发送到文本文件。我遇到的问题是: fprintf()不能识别新的命令行( \\\
),返回命令( \r )。我正在使用的代码是

$ $ p $ $ $ $ c $ fid = fopen([Image.Dir,'CtlPts _',Image.Files {k}, '.txt文件 '],' W');
fprintf(fid,'%。4f\t%.4f\\\
',control_points {k});
fclose(fid);

其中我要打印的数据位于单元格 control_points {k }



标签打印正常,但文本文件中的所有内容都打印在一行上,所以这就是为什么我假设它是忽略我的新行字符。



我的语法有什么问题,我没有看到?


I am trying to send an array that is [2 x N] doubles large to a text file using the fprintf() command. I am having problems in that fprintf() is not recognizing the new line command (\n) or the carriage return command (\r). The code I am using is

fid = fopen([Image.Dir,'CtlPts_',Image.Files{k},'.txt'],'w');
fprintf(fid,'%.4f\t%.4f\n',control_points{k});
fclose(fid);

where the data I am trying to print is in the cell control_points{k}.

The tab gets printed fine, but everything in the text file gets printed on one line, so this is why I am assuming that it is ignoring my new line character.

Is there something wrong with my syntax that I am not seeing?

解决方案

I know that on many systems, \n is not enough to create what you're asking for (and so, maybe you have to do \r\n)

这篇关于fprintf不打印新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆