Write a program to read multiple lines from a file “sitd.txt” using getline() function


 

/* Write a program to read multiple lines from a file “sitd.txt” using getline() function*/

#include<fstream.h>

#include<process.h>

#include<conio.h>

void main()

{

clrscr();

ofstream fout(“sitd.txt”);

if(!fout)

{

cerr<<“file cannot open”;

exit(-1);

}

fout<<“my name is harjeet\n”;

fout<<“i study in mca class\n”;

fout<<“i am an allrounder\n”;

getch();

}

/* output:

my name is harjeet

I study in mca class

I am an allrounder*/

Related Posts

Comments are closed.