Convert textfile to string

hello this is code which doesnot work

void ViewData(){

system("CLS");

ofstream mydata;
mydata.open("Data.txt");
while (!mydata.eof()){
getline(mydata,line);
cout <<line<<endl;



}

}





i think logic is not bad but it says getline is overloaded , so

it opens file and while there is no end of fileit will get each line to a variable called line and output it , when there is eof it will stop this is just part of HUGE program but idk where is the problem please help me it should output whole file like this is file :

Hello

xyz

fjebjebgeo


it should output text with same spaces exactly line by line and i think my code should do that pls help
Topic archived. No new replies allowed.