Skip to content

Commit 26119cb

Browse files
author
Sumit tripathi
committed
Update file input/output example and modify content in FileInputOutput.txt
1 parent 2e6c572 commit 26119cb

3 files changed

Lines changed: 30 additions & 2 deletions

File tree

FileInputOutput.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ int main(){
3232
return 0;
3333
}
3434
35-
*/
35+
3636
3737
int main(){
3838
ofstream out("FileInputOutput.txt");
@@ -46,4 +46,30 @@ int main(){
4646
in >> content;
4747
cout << "The file of this file is " << content;
4848
return 0;
49+
}
50+
51+
52+
*/
53+
54+
int main(){
55+
ofstream out;
56+
out.open("FileInputOutput.txt");
57+
out << "This is me\n";
58+
out << "This is me alsoo\n";
59+
out << "I'm an software engineer";
60+
out.close();
61+
62+
ifstream in;
63+
string st;
64+
in.open("FileInputOutput.txt");
65+
// in >> st;
66+
// cout << st;
67+
68+
while (in.eof()==0) //eof -> end of file
69+
{
70+
getline(in, st);
71+
cout << st << endl;
72+
}
73+
in.close();
74+
return 0;
4975
}

FileInputOutput.exe

-236 Bytes
Binary file not shown.

FileInputOutput.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
My name is Sumit
1+
This is me
2+
This is me alsoo
3+
I'm an software engineer

0 commit comments

Comments
 (0)