473,394 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Help Degugging My Program

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(char*, 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(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(int counter = 0; counter < size; counter++)
{
cout << array[counter] << 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;
}
Nov 11 '06 #1
1 2505
horace1
1,510 Expert 1GB
have a look at
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int numNames = 10;
  5. const int nameSize = 17;
  6. void showArray(char [][nameSize],char);   // ** correct array size
  7. void selectionSort(int [][nameSize], int);
  8. int main()
  9. {
  10. char names [numNames][nameSize]=
  11. {"Collins,Bill",
  12. "Smith,Bart",
  13. "Allen,Jim",
  14. "Griffin,Jim",
  15. "Stamey,Marty",
  16. "Rose,Geri",
  17. "Taylor,Terri",
  18. "Johnson,Jill",
  19. "Allison,Jeff",
  20. "Looney,Joe"};
  21.  
  22. showArray(names,numNames);
  23.  
  24. }
  25. void showArray(char array [][nameSize], char size) // ** add [nameSize]
  26. {
  27. for(int counter = 0; counter < size; counter++)
  28. {
  29. cout << array[counter] << endl;
  30. }
  31. }
  32.  
  33. void selectionSort(char array[][nameSize],int size)  // ** remove ,
  34. {
  35. int counter, minRow;     // ** int
  36. char minValue[17];
  37.  
  38. for(counter = 0; counter < (size - 1); counter++)  // ** SIZE to size
  39. minRow = counter;
  40. strcpy(minValue,array[counter]);                 // ** removed = added ); on end of line
  41. for(int index = counter+1; index < size; index++)  // ** SIZE to size
  42. { if(strcmp(array[index],minValue)<0)
  43. strcpy(minValue,array[index]);
  44. minRow = index;
  45. }
  46. }
  47.  
  48.  
Nov 11 '06 #2

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

Similar topics

4
by: PHPkemon | last post by:
Hi there, A few weeks ago I made a post and got an answer which seemed very logical. Here's part of the post: PHPkemon wrote: > I think I've figured out how to do the main things like...
6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
2
by: John Baker | last post by:
I find it highly annoying that MS Access tries to go online when I want to look at the help files. Is there a way to configure it so it just looks at my local helpfiles when I hit F1?
5
by: Bec | last post by:
I'm in desperate need of your help.. I need to build an access database and have NO idea how to do this.. Not even where to start.. It IS for school, and am not asking anyone to do my...
4
by: Tarique Jawed | last post by:
Alright I needed some help regarding a removal of a binary search tree. Yes its for a class, and yes I have tried working on it on my own, so no patronizing please. I have most of the code working,...
15
by: Buck Rogers | last post by:
Hi guys! Task 1: Write a program which presents a menu with 5 options. The 5th option quits the program. Each option should execute a system command using system(). Below is my humble...
7
by: tyler_durden | last post by:
thanks a lot for all your help..I'm really appreciated... with all the help I've been getting in forums I've been able to continue my program and it's almost done, but I'm having a big problem that...
6
by: HelpME | last post by:
I wrote a program in Vb.Net that was running fine. However I am unable to install it on a couple of machines. When i run it I get a windows error message that says My Project.exe has...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.