oh ok thanks. Actually the compiler was right.
But now I have to sort the words. The following is my sorting code, but it gives me a lot of errors for some reason.
If someone could just tell me a general problem for the code, I would really appreciate it. Thanks in advance
Code:
Code:
void SelectionSort(int arr[][MAX_WORD_LENGTH+1], const int size)
{
int smallest_index;
for (int i= 0; i <=size; i++)
{
smallest_index = i;
for (int j = i + 1; j <= size; j++)
{
if (strcmp(arr[j],arr[smallest_index]) < 0)
{
smallest_index=j;
}
}
swap(arr[i],arr[smallest_index]);
}
}
void swap_words(char arr[],char arr2[])
{
char temp[strlen(arr1)];
strncpy(temp,arr1,strlen(arr1));
strncpy(arr1,arr2,strlen(arr2));
strncpy(arr2,temp,strlen(temp));
}
Errors:
test.c: In function `void SelectionSort(int (*)[26], int)':
test.c:67: error: cannot convert `int*' to `const char*' for argument `1' to `in
t strcmp(const char*, const char*)'
test.c: In function `void swap_words(char*, char*)':
test.c:79: error: `arr1' undeclared (first use this function)
test.c:79: error: (Each undeclared identifier is reported only once for each fun
ction it appears in.)
test.c:80: error: `temp' undeclared (first use this function)
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_algobase.h: In function `
void std::swap(_Tp&, _Tp&) [with _Tp = int[26]]':
test.c:73: instantiated from here
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_algobase.h:130: error: in
valid initializer
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_algobase.h:131: error: IS
O C++ forbids assignment of arrays
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_algobase.h:132: error: IS
O C++ forbids assignment of arrays