每次在下一行中顺序写入文本文件 [英] Write to a text file sequentially every time in next line

查看:162
本文介绍了每次在下一行中顺序写入文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我如何每次从下一行开始就写入文本文件,例如说我有一个文本文件"test.txt",并且我有一个迭代代码,打印时说你好",我要打印的是你好每次这样的下一行

你好
你好
你好

到目前为止,我已经使用

Hello

How can i write to a text file every time start from the next line, for example say i have a text file "test.txt" and i have an iterative code that prints say "hello" what i want is hello to be print on next line every time like this

hello
hello
hello

so far i have used

 ta='text.txt';
fid = fopen((ta), 'a');
Loop{ fprintf(fid,'%s\n',word); }


推荐答案

在我看来,您的循环永无止境...为什么?了解有关循环的更多信息: http://www.mathworks.com/help /search/doccenter/zh-CN/R2012b?qdoc = loops& submitsearch = Search [ http://www.mathworks.com/help/matlab/import_export/writing-to-text-data-files-with-low-level-io.html# br5_kad-1 [
In my opinion your loop never ends... Why? Read more about loops: http://www.mathworks.com/help/search/doccenter/en/R2012b?qdoc=loops&submitsearch=Search[^]

If you would like to write the data at the end of existing file, read this: http://www.mathworks.com/help/matlab/import_export/writing-to-text-data-files-with-low-level-io.html#br5_kad-1[^]


这篇关于每次在下一行中顺序写入文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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