Discussion Forums > Technology
C++ help
Fr0steh:
hey! pointers are teh r0x when you know how to use them! they just dont make coffee XD
edit: oh wait! they do make coffee if for some reason the pointer is accessed by a coffee machine!! xD
Slykester:
Your best starting point, and the best advice you have been given is
(click to show/hide)
--- Quote from: Pzc on July 21, 2009, 11:04:43 AM ---Since you allocate the array with new methinks
it should look like this:
--- Code: ---
void sort(double *arry, int); <== function prototype
void sort(double *arry, int size) <===== function definition
--- End code ---
You should also delete everything you new:
--- Code: ---
...
cout << "Average test score: " << average << endl;
cout << "****************************" << endl;
delete [] scores;
}
--- End code ---
--- End quote ---
Yes, definitely that ;) I take it this is for an assignment?
ant900:
Deleting memory does tend to be a good thing.
Also that bubble sort is pretty ugly IMO, you should try using a faster algorithm or clean that up.
Proin Drakenzol:
iirc
void sort(double array[], int num)
should work.
it's been about five years since I last used C++, though. I used Java in college and haven't programmed at all since joining the Navy.
xShadow:
Yeah, but you have to modify a few variables in the actual function if you're gonna go that route. I outlined that in the post with the correction I suggested.
To be honest, though, I just now noticed that me and Pzc essentially told him to do the same thing at the beginning, but apparently people misunderstand each other on the internetz very easily. >_>
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version