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");

Recommended Answers

All 2 Replies

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.

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");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.