By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,605 Members | 1,391 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,605 IT Pros & Developers. It's quick & easy.

Help Asap Debugging My Program

P: 15
I am trying to write a program which sorts an array of supplied names.

Here are the errors i am getting.


33: error: expected unqualified-id before "for"
37: error: expected declaration before '}' token


AND HERE IS MY CODE

#include <iostream>
using namespace std;

const int numNames = 10;
const int nameSize = 17;
void showArray(char [],char);
void selectionSort(int [], int);
int main()
{
char names [numNames][nameSize]=
{"Collins,Bill",
"Smith,Bart",
"Allen,Jim",
"Griffin,Jim",
"Stamey,Marty",
"Rose,Geri",
"Taylor,Terri",
"Johnson,Jill",
"Allison,Jeff",
"Looney,Joe"};

showArray(names[10],numNames);

}
void showArray(char array [], char SIZE);

for(counter = 0, counter < size, counter++)
{
cout << array[count] << endl;
}
}

void selectionSort(char array[],[nameSize],int size)
{
cin counter, minRow;
char minValue[17];

for(counter = 0; counter < (SIZE - 1); counter++)
minRow = counter;
strcpy =(minValue,array[counter]

for(int index = counter+1; index < SIZE; index++)
{ if(strcmp(array[index],minValue)<0)
strcpy(minValue,array[index]);
minRow = index;
}




Any help is greatly appreciated.
Nov 11 '06 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 1,510
there were a few errors in function showArray(), e.g.
Expand|Select|Wrap|Line Numbers
  1. void showArray(char array [], char size)  // ** removed ; change SIZE to size
  2. {                                         // ** added {
  3. for(int counter = 0; counter < size; counter++)   // ** replace, with ;
  4. {
  5. cout << array[counter] << endl;                   // ** changed count to counter
  6. }
  7. }
  8.  
now try and find errors in the rest of the code
Nov 11 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.