File write problem

I am not using any "/n" or "endl" then also my file stores the data every time in a newline. I don't know why.

Can anyone explain!



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include"header.h"

int main()
{
int roll_number;
string name;
time_t in_time = time(0);

//user input
cout<<"\nenter Roll Number of student: -";
cin>>roll_number;
cout<<"\nenter name of student: -";
cin>>name;
cout<<"\nArrival time of the Student is : ="<<ctime(&in_time)<<endl;

//File write operation
ofstream fileinput;
fileinput.open("student.txt", ios::app);
fileinput<<"Student"<<", "<< roll_number <<", "<< name <<", "<< ctime(&in_time);
fileinput.close();
cout << "\nRecord Added Successfully\n";

return 0;
}



student.txt
Student, 2002, Tom, Tue Jan 25 11:32:07 2022
Student, 5443, Samuel, Tue Jan 25 11:32:29 2022
THANKYOU @salem c
Topic archived. No new replies allowed.