Why are you still using void main?
http://www.research.att.com/~bs/bs_faq2.html#void-main
http://c-faq.com/ansi/maindecl.html
It's wrong pure and simple, and just because your compiler accepts it doesn't make it any more right.
Plus, you need to work on your indentation as well. If it looks better in your IDE (everything lined up nicely) than in your post above, then think about turning off hard tabs for indentation.
You open the file.
You use a loop to do say
fin >> y[i];
You close the file
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
arr is not an array its and int. line 40.
Agni
Practically a Master Poster
655 posts since Dec 2007
Reputation Points: 431
Solved Threads: 116
what i think you're supposed to do is, you need to read some stuff about datatypes in c++ and then revisit the code.
Agni
Practically a Master Poster
655 posts since Dec 2007
Reputation Points: 431
Solved Threads: 116
y is a single integer, so it cannot be passed to the functions as such. You need an array of integers holding the data you have read in.
int main()
{
enum { ARR_SIZE = 3 };
int y[ARR_SIZE] = {0}; // Array of ints, at max ARR_SIZE elements
int count = 0; // number of elements read into the array
ifstream infile("jes.txt");
while(count < ARR_SIZE && infile >> y[count])
{
cout << " " << y[count] << "\n";
++ count;
}
cout << "read in " << count << " numbers ...\n";
// sort the numbers
selectionSort(y, count);
return 0;
}
mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395