Quote:
Originally Posted by shabbir
use \r\n instead of \n and see what happens.
Sir ! I tried this code. but It removes the First character of First Line.
Source is:
Code:
#include<iostream.h>
#include<conio.h>
#include<process.h>
#include<fstream.h>
void main()
{
char sample[1000];
ofstream myfile;
myfile.open("c:/example.txt");
myfile<<"Writing in the file.";
myfile<<"\r \n Next line";
cout<<"Done";
}
Output in file is :
Code:
riting in the file.
Next Line
But I don't understand how did it happen? Like if I tell what i understands from this code.
I take example of notepad here. Like I opened a text file in notepad. I typed "Writing in the file" then I press HOME key on key board which is I think equivalent to \r(Carriage Return).
Then I type Next Line. Now the Output would be here as follows :
Code:
Next LineWriting in the file.
Kindly make me understand.