I am trying to write a program which sorts an array of supplied names.
These are the errors i am getting.
.cpp:39: error: expected identifier before '[' token
40: error: ISO C++ forbids declaration of `parameter' with no type
In function `void selectionSort(c har*, int*, int)':
41: error: expected `;' before "counter"
44: error: `counter' was not declared in this scope
44: error: `SIZE' was not declared in this scope
45: error: `minRow' was not declared in this scope
48: error: expected `)' before "for"
48: error: `SIZE' was not declared in this scope
error: ISO C++ forbids incrementing a pointer of type `char*(*)(const char*, int) throw ()'
48: error: non-lvalue in increment
48: error: expected `;' before ')' token
52: error: expected `}' at end of input
HERE IS MY CODE
/* Matt Deshong
mgd156
Sorting by Selection
Write a program which sorts an array of supplied names (character strings).
*/
#include <iostream>
using namespace std;
const int numNames = 10;
const int nameSize = 17;
void showArray(char [],char);
void selectionSort(i nt [], int);
int main()
{
char names [numNames][nameSize]=
{"Collins,Bill" ,
"Smith,Bart ",
"Allen,Jim" ,
"Griffin,Ji m",
"Stamey,Mar ty",
"Rose,Geri" ,
"Taylor,Ter ri",
"Johnson,Ji ll",
"Allison,Je ff",
"Looney,Joe "};
showArray(names[10],numNames);
}
void showArray(char array [], char size)
{
for(int counter = 0; counter < size; counter++)
{
cout << array[counter] << endl;
}
}
void selectionSort(c har array[],[nameSize],int size)
{
cin counter, minRow;
char minValue[17];
for(counter = 0; counter < (SIZE - 1); counter++)
minRow = counter;
strcpy =(minValue,arra y[counter]
for(int index = counter+1; index < SIZE; index++)
{ if(strcmp(array[index],minValue)<0)
strcpy(minValue ,array[index]);
minRow = index;
}
These are the errors i am getting.
.cpp:39: error: expected identifier before '[' token
40: error: ISO C++ forbids declaration of `parameter' with no type
In function `void selectionSort(c har*, int*, int)':
41: error: expected `;' before "counter"
44: error: `counter' was not declared in this scope
44: error: `SIZE' was not declared in this scope
45: error: `minRow' was not declared in this scope
48: error: expected `)' before "for"
48: error: `SIZE' was not declared in this scope
error: ISO C++ forbids incrementing a pointer of type `char*(*)(const char*, int) throw ()'
48: error: non-lvalue in increment
48: error: expected `;' before ')' token
52: error: expected `}' at end of input
HERE IS MY CODE
/* Matt Deshong
mgd156
Sorting by Selection
Write a program which sorts an array of supplied names (character strings).
*/
#include <iostream>
using namespace std;
const int numNames = 10;
const int nameSize = 17;
void showArray(char [],char);
void selectionSort(i nt [], int);
int main()
{
char names [numNames][nameSize]=
{"Collins,Bill" ,
"Smith,Bart ",
"Allen,Jim" ,
"Griffin,Ji m",
"Stamey,Mar ty",
"Rose,Geri" ,
"Taylor,Ter ri",
"Johnson,Ji ll",
"Allison,Je ff",
"Looney,Joe "};
showArray(names[10],numNames);
}
void showArray(char array [], char size)
{
for(int counter = 0; counter < size; counter++)
{
cout << array[counter] << endl;
}
}
void selectionSort(c har array[],[nameSize],int size)
{
cin counter, minRow;
char minValue[17];
for(counter = 0; counter < (SIZE - 1); counter++)
minRow = counter;
strcpy =(minValue,arra y[counter]
for(int index = counter+1; index < SIZE; index++)
{ if(strcmp(array[index],minValue)<0)
strcpy(minValue ,array[index]);
minRow = index;
}
Comment