Hello All,

Can I use cin.getline(x,y) to read a line from a file?

What is the form of cin.getline(x,y) when used with files?

What I need to do is to output what I have written to a file to the console.

I have the file open, using ofstream, and I save names to it. Then I close the file and re-open it, using ifstream, and want to read what I have saved to it.

Thanks a lot for any suggestions.

ifstream fin
fin.getline

cin and cout just happen to be streams already opened for you. Otherwise, everything else is identical.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.