Does anyone know why this read function won't work?

I have a function that Reads a file called "videos.txt". For some reason it is not reading the text from Videos.txt. Does anyone see a problem with the code? I've been looking over it for about an hour and it looks fine to me..Any help would be greatly appreciated. Thank you so much.



void MeTube::Read_Video(MeTube Video[], int &count)

{



ifstream din;
din.open("videos.txt");
if (din.fail())
cout << "Could not open videos.txt" << endl;

string str;
getline(din, str);
count=atoi(str.c_str());



for (int i=0; i<count && !din.eof(); i++)
{
getline(din, str);
Video[i].setTitle(str);
getline(din, str);
Video[i].setHandle(str);
getline(din, str);
Video[i].setCategory(str);
getline(din, str);
Video[i].setRating(atoi(str.c_str()));
getline(din, str);
Video[i].setLength(atof(str.c_str()));
getline(din, str);
Video[i].print();
}

din.close();

}
Last edited on
Topic archived. No new replies allowed.