Hello ladies and gents, could someone explain what I'm doing wrong here, the ideas of this excercise is:
- Declare an array with 10 firstnames using pointers!
- Show the array on screen using a function!
- Sort out the names alphabetically and show the array again sorted!
I want to try and write the program first just getting the ten names into the array using pointers, but there seems to be something wrong, message I keep getting is:
error C2664: 'inhoud' : cannot convert parameter 1 from 'char [10]' to 'char *[]'
I tried to use the library MSDN, but I don't fully understand the example that is being given in it?
This is my code:
void inhoud(char *naam[]);
int main()
{
char naam[10];
cout<< "Voer tien voornamen in: " <<endl;
inhoud(naam);
return 0;
}
void inhoud(char *naam[])
{
for (short i=0; i<10;i++)
{
naam [i]= new char [20];
cin.getline(naam[i], sizeof naam);
}
}
Could someone please explain this please, I don't want someone to give the solution, but if you could give me an example how it should be written and why you wrote it that way, I would appreciate it alot. ;)