Here is the actual homework problem. I am stuck on parts 1 and 2 and I really don't know how to make this right. Any help is greatly appreciated.
1. Write a C++ program that reads following data from an input file called “in.txt”, And stores them to an array called Grade, you need to use a function to read this data:
89 56 75 48 34 93 62
2. Display this data on screen to make sure you read data correctly
a. You must use a function to display this data
3. Write a function that gets the array of grades (numbers you read from input file), Size of array as two value parameters, and returns sum of those grade, as reference parameter to main, then print it to the output file.
4. Write a function to sort this array. Now print unsorted & sorted array to an output file, called “output.txt”
5. Write a function to search for one of the grade above (like 34), then print the location of the item and say you found it
#include <iostream>
#include <fstream>
using namespace std;
//=========== Prototypes for functions =======================
int Read(int grade[7]);
int main()
{
cout<<"These are the grades stored in the array: "
<<Read<<endl;
//========== Functions Definition Read File ===============================
int Read(int grade[7])
{
ofstream out; //Creates an instance of ofstream
ifstream in; //Creates an instance of ifstream
in.open("c:\\in.txt"); //opens inputfile.txt
out.open("c:\\out.txt"); //Opens outputfile.txt
in.close(); //Close input file
out.close(); //Close outputfile
}
}
I keep getting the error:
error C2601: 'Read' : local function definitions are illegal
I don't know what else is wrong pass that point so could you help me figure that out. Thank you.