new to c++,stuck on assignment

i am new to c++ and have this assigment to do and i am having problems with all of it basically, reading in from a file, creating the functions etc. i ended up deleting the code i wrote for it because there was just too many errors. can anyone give me code for this and give lots of comments so i could go through it step by step to see whats goin on? it would be a great help to me. i am not to use classes in this program. and i am to use selection sort to sort the numbers from high to low.
the assigment is below.



"The following Program sorts a list of integer numbers read in from the file numbers.dat (obviously not sorted in this file ). The maximum number of integers in the file is 20. The first number in the file is the number of integers in the file. The values when sorted will be printed to the file sorted.txt. Write this program will 3 function to read in, sort and write out the data."

#include <iostream.h>
…….any required header files ???
void getvalues( int array[], int size ) ;
void sort( int array[], int size ) ;
void outvalues( int array[], int size ) ;
main()
{
.........put in code
return 0;
}
can anyone give me code for this and give lots of comments so i could go through it step by step to see whats goin on?


Well, no, it's against the rules for us to do you homework.

Your school must have given you enough info to be able to do the assignment.

You need to provide much more input from yourself before we can help.

If you write code & have lots of errors - then post the compiler output & we can explain what it all means.
ok thats fair enough.
here is what i have written for the function to read in from the file. i think the funtion is close enough to doing what i want but i amn't sure how to call it in the main program,in particular what goes in the brackets after getvalues.. these are the errors i got
Error 1 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 2 error C2660: 'getvalues' : function does not take 0 arguments



main()
{
getvalues() ;
return 0;
}

void getvalues( int array[], int size )
{
ifstream ip("c:\\numbers.dat");
ofstream op("c:\\sorted.txt");
ip>>size;
for(int num=0; num< size; num++)
ip>>array[num];
ip.close();

}


Please use code tags - the <> button on the right.

I can't help thinking that you are going to really struggle if you don't know how to call a function.

Either the assignment is far beyond your capabilities (maybe you slept through all the lectures) or you are trolling.

If not, then provide much better evidence to show you have made an effort.
To make it clearer...

Where is the return type for your main function?
And also, your function has no default arguments(args), and it takes two args so you cannot call it without passing the two args of the specified type.

Thanks,
Aceix.
Topic archived. No new replies allowed.