Good to hear, but I have a few suggestions to make:
- Break up your main function into smaller functions that do one thing and do it well.
- #include <vector> and change buffer to a std::vector<char> into of doing manual memory management.
- Declare variables near first use. If possible, declare them at the point where you can provide them with sensible initial values. In fact, you should change this:
to a one-liner that initialises the object:Code:ifstream inFile; // Initiate the input file stream inFile.open("C:\\datafile.txt", ifstream::in);
Code:ifstream inFile("C:\\datafile.txt");- You only use the non-standard getch() at the end, presumably to pause the program. Since you are not using anything else from the non-standard <conio.h>, you might as well get rid of that header inclusion and use a more portable alternative to getch() for this purpose.