My goal is to make a program that opens a .dat file and it checks to see if the number exists in the file. If it does, it tells where that number is. I need a very simplified C++ answer, because I am a beginner and new to this. Then, I need a program that reads the entire data file and tells the user whether each number is even or odd, and then totals them. I need help ASAP. Thank you in advance! Here is my file so far...please finish!
#include <cstdlib>
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int value;
ifstream number_file;
cout << endl << "Opening file: numbers.dat..." << endl;
number_file.open("numbers.dat");
if (number_file.fail())
{
cout << "Failed to open file." << endl; exit(1);
}
cout << "Enter a numerical value to see if it exists in that file: ";
cin >> value;
int count = 0;
do {
cout << endl << count << " " << value;
count++;
} while (number_file >> value);
cout << endl;
number_file.close();
return 0;
}