How can I retrieve strings using getline and enter them into a 2 d aray?

C++. For example the user enters the name Fionna Issac as one whole string. This string is then to be entered into the two dimensional array seats[2][4].
I don't know. What does the seats array represent? Check the articles database. there are a couple of articles and tutorials on multidimensional arrays. Do that or post an example of what you are trying to do and show us how the seats array is declared.
In C++ you use getline(cin, array_name). The array usually looks like: string first_last_names[81];
But I wonder why you want to use a two dimensional array.
Your names will still be separated by a space character in a one dimensional array and so just as easily read.
OK.. I missed the significance of the 'seats' array.
First get the name and store it in char s[81].
1
2
3
do
cin.getline(s,81);
while(*s>='a' && *s<='z');


Then assuming you want the name in first column of first row...transfer the name to seats[0][0]

1
2
3
4
5
6
for(int i=0;i<2;i++)  
   {  for(int j=0;j<4 ;j++) 
        if(i==0 && j==0) 
         for(int m=0;m<strlen(s);m++)
         seats[0][0]=s[i];
   }

......i think!
What's wrong with std::string?
Your second snippet makes absolutely no sense.
Topic archived. No new replies allowed.