473,657 Members | 2,504 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help Degugging My Program

15 New Member
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;
}
Nov 11 '06 #1
1 2522
horace1
1,510 Recognized Expert Top Contributor
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
2747
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 storing products in
6
4331
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 result in any way. Who can help me, I thank you very very much. list.cpp(main program) //-------------------------------------------------------------------------- - #pragma hdrstop #pragma argsused
2
2544
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
3004
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 homework for me.. I am merely asking for help, perhaps pointers as to where to begin.. I've never used access before.. I'm rather cluey when it comes to
4
9013
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, even the removal, I just don't know how to keep track of the parent, so that I can set its child to the child of the node to be removed. IE - if I had C / \ B D
15
2736
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 offering. =================================================== #include <stdio.h> #include <stdlib.h>
7
3278
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 I believe if it's solved, the remaining stuff is easy... my full program until now is here: http://www.geocities.com/tom4_h4wk/progmail.zip the problem is the segmentation fault when main trys to run leficheiro.c.... the *.c2 files are the...
6
1632
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 encountered a problem and needs to close. We are sorry for the inconvience. If you were in the middle of something, the information you were working on might be lost
0
8421
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8325
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8621
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7354
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.