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.

pointer help

P: 14
using namespace std;

const int index=5;
void getName(char,int);

int main()

char string[21];
char *aString=string;
for(int count=0;count<index;count++)

cout << "you entered";
cout << names;

return 0;

void getName (char names[][21], int index)
cout << "enter a name: ";
cin >> names[index];
I need to enter a name 5 times
Nov 15 '06 #1
Share this Question
Share on Google+
1 Reply

P: 175
you've got a bunch of mistakes in your code. I would suggest trying to write the code without pointers, THEN worrying about the pointers after it works without them.

one thing that's wrong are the variables you're passing, two of them aren't the right ones...the index of your array will always be set to [5], it should go up or down, and in the function definition, you're using a pointer not a 2-dimensional array, so it can't be passed like that. There's not that much to pointers once you figure out how they work, but knowing how to do other stuff is more important.
Nov 15 '06 #2

Post your reply

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