I am new to C++ and I have been pulling my hair out trying to accomplish this simple task.
I have been able to open a text file and scan it's contents. When I do this it prints to screen the entire document. I want to be able to only display it on a single line as if it was flickering through each line or (scanning it). Is there a way to detect the carriage return then go back to the beggining of the display line and show the next one. Here is my code. Any help would be much appriciated.
#include <fstream.h>
#include <iostream.h>
#include <stdio.h>
int main(void)
{
char contents[50000];
char filename[30];
if (filename != "*"){
cout << "What file do you want to display? PRESS * To QUIT---->";
cin.getline(filename, 30, '\n');
ifstream file(filename);
cout << filename;
do
{
file.getline(contents, 50000, '\n');
cout << contents;
cout << "\n";
}
while (file.eof()!=1);
file.close();
cout <<"Done reading file";
}
return 0;
}
Thank You,
Jay