hi guys..! i need some help on how can i print out the output of my program.. the problem is, it will only print out the first char of a characters and i don't know how to use the pointer using an multidimensional array.
ex.
input:
jhonny
output:
j
here's my code:

char name[5][50];
*p;
for(i=0;i<5;i++)
 {
  cin.getline(name[i], 50)
 }
for(i=0;i<5;i++)
 {
 cout<<"*name[i]<<"\n";
  }

..i am using a string here..
guys i need your help for this..
i will appreciate your help so much.

thanks..

There a a bunch of different solutions. One being

char name[5][50];

	for(int i=0; i<5; i++)
	{
		char buffer[50];
		cin.getline(buffer, 49);
		buffer[strlen(buffer)] = '\0';
		strcpy(name[i], buffer);
	}

	for(int i=0;i<5;i++)
	{
		cout << name[i] << endl;
	}

but you should look in to using std::string instead

You almost got it right .

char name[5][50];
for(int i=0;i<5;i++)
 {
  cin.getline(name[i], 50);
 }
for(int i=0;i<5;i++)
 {
 //or cout<<name[i]<<"\n";
  cout<<**(name+i)<<endl;
  }
*name[i]

is equivalent to

**(name+i)

which displays only the first character of the line entered.
Also you don't require a buffer as

cin.getline(...)

automatically appends a '\0' .

This article has been dead for over six months. Start a new discussion instead.