954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to write enter in text file

Hi everybody,

I want to write enter in a text file. How to do this. I wrote the code as follows. see if i write like this, it is printing one special character like arrow. I want to print in the following line, instead it is printing in single line with arrow.

How to do next line in the file write..

fprintf(out_fp,"----------------------------------------------------------\n");
fprintf(out_fp,"\tFBNO  FBCode         入力FB番号    出力FB番号  \n");
fprintf(out_fp,"----------------------------------------------------------\n");
ambarisha.kn
Junior Poster in Training
66 posts since Jun 2008
Reputation Points: 25
Solved Threads: 0
 

how was the file opened? as text or binary? If binary then the next line character(s) depends on the operating system. In MS-Windows/MS-DOS you need "\r\n". *nix just "\n" and MAC "\r". If the file is opened in text mode then the operating system will make the appropriate translation of "\n" to whatever it needs.

I tried your three lines and it seemed to work ok for me. Opened the file with Notepad.exe and it looked ok (except for the Chinese characters). What editor are you using? If not English language then find out what it expects as line feeds.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Before i was opened the file as follows.

out_fp = fopen(oppath,"wb");


i am not writing into dat file. I am writing to text file. so i changed the code as follows and its working fine.. thanks

out_fp = fopen(oppath,"w");
ambarisha.kn
Junior Poster in Training
66 posts since Jun 2008
Reputation Points: 25
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You