How to insert new line text in a file?

2 ビュー (過去 30 日間)
leo john
leo john 2020 年 5 月 23 日
編集済み: leo john 2020 年 5 月 24 日
fid1 = fopen('sample1.txt', 'a');
fprintf(fid1, '\n First line a b c d e f g h\n');
fclose(fid1);
fid2 = fopen('sample2.txt', 'a');
fprintf(fid2, '');
fprintf(fid2, '\nNew message in new line\n');
fclose(fid2);
Merge those two files into single file sample3.txt
I want to print those two lines one by one like below:
First line a b c d e f g h
New message in new line
Kindly do the needful
  2 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 5 月 23 日
What is the error in your code? Also, there is no need to use two newlines.
leo john
leo john 2020 年 5 月 24 日
Suppose if i want to merge two files each file containing one line, after merging it i want the file with two separate lines which i am not able to done. Instead it is printing in the same line.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeJSON Format についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by