Hi Everyone,
I want to reference count in the ReadFile function. That works fine, however I also want to pass th my sort function is not working. Please help.
Code://Functions.h #include <iostream> #include <fstream> #include <string> using namespace std; bool ReadFile (int myArray[], int &t); int sortArray(arr, count); int main() { int i = 0; int &count = i; int arr[300]; fileFound=ReadFile(arr, count); sortArray(arr, count); cin.get(); exit(1); } //Functions.cpp #include <fstream> //for ifstream #include <string> using namespace std; #define FILE_IN "Numbers.txt" bool ReadFile (int myArray[],int &t) { ifstream rdFile; //Input Object rdFile.open(FILE_IN); int n; if (!rdFile) { return false; } else while(!rdFile.eof()) { rdFile >> n; myArray[t]= n; ++t; } rdFile.close(); return t; return true; } void sortArray(int myArray[], int &t) { int i , j, temp; for (i = 0; i < t; i ++) { for (j = i; j< t; ++j) { if (myArray[j-1] >myArray[j]) { temp = myArray[j]; myArray[j] = myArray[j-1]; myArray[j-1] = temp; } } } }


Reply With Quote


Bookmarks