I'm trying to make a simple DOS C++ text editor. I figured out how to save to the file when you create a new document, now I'm having trouble viewing existing files. The program won't stop looping. (or repeats the last word over and over until the loop finish value is set). I'm pretty sure I need to use pointers and have it fine the '\0' (null byte) or something... Here's a snippet from the load function:
I'm aware as of now that it only opens and displays files in the same directory that the program is installed into, that doesn't bother me. I need to know how to make it so that the program knows where the EOF is...Code:int loadFile() { char fileNameLoad[12], text[25], a; header(); //seperate function just to view colors :D cout<< "\nEnter file name: "; cin>> fileNameLoad; ifstream viewFile(fileNameLoad); //opens fileNameLoad for viewing cout<< "\nContents of file:\n"; while (text != '\0') // ??? { viewFile>> text; cout<< text << " "; } cout<< "\n\nPress any key to return to Main Menu..."; viewFile.close(); getch(); return 0; }
Thanks!