Hey guys
I am having a bit of trouble with these errors,
and I cannot see what I have done wrong. I have looked the compiler error
number up and it says to try to
comment out the lines above it to see the error exactly, but if I do that I will
get a ton more cause the error line is just the function definition.
The code swaps array elements into ascending order using pointer notation
Code:
#include <stdio.h>
#define SIZE 10
/*function prototypes*/
void sortArray ( int*, const int );
void swapElements ( int *const, int *const );
/*main function*/
int main ( void ) {
int data[ SIZE ] = { 2, 4, 6, 8, 10, 1, 3, 5, 7, 9 },
counter;
printf("Original array output:\n\n");
for ( counter = 0; counter < SIZE; counter++ ) {
printf(" %d", data[ counter ]);
}
/*sort into order*/
sortArray( data, SIZE );
printf("\n\nSorted array output:\n\n");
for ( counter = 0; counter < SIZE; counter++ ) {
printf(" %d", data[ counter ]);
}
getchar();
return 0;
}
/*function to sort the array into acsending order*/
void sortArray ( int *array, const int SIZE ) { ERROR LINE
int counter,
pass;
for ( counter = 0; counter < SIZE -1; counter++ ) {
for ( pass = 0; pass < SIZE -1; pass++ ) {
if ( array[ pass ] > array[ pass +1 ] ) {
swapElements( &array[ pass ], &array[ pass +1 ] );
}
}
}
}
/*function to swap the elements over usihng pointer notation*/
void swapElements ( int *const ElementPtr1, int *const ElementPtr2 ) {
int temp = *ElementPtr1;
*ElementPtr1 = *ElementPtr2;
*ElementPtr2 = temp;
}
The errors:
Code:
main.c(48): error C2059: syntax error : ')'
main.c(48): error C2059: syntax error : '<Unknown>'
main.c(48): error C2143: syntax error : missing ')' before 'constant'
main.c(48): error C2143: syntax error : missing '{' before 'constant'
Im using MS VC++ 2003.net IDE
I really appriciate any tips and help