954,535 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to read an array of strings in C++

hi all! i m trying to input an array of strings same as we input array of integers. by declaring a 2 dimensianal array runnig 2 for loops like

for(i=0;i<m;i++)
for(j=0;j<n;j++)
cin>>arr[i,j]

plz help me i m in great confusion because by doing in this way, i m not getting the actual no of strings

Gaurav arora
Junior Poster in Training
59 posts since Mar 2007
Reputation Points: 10
Solved Threads: 0
 

No need to that a way.
Here's how you could do that:

char str[5][50];
for(int i=0; i<5; i++)
{
     cin >>  str[i];
}
vishesh
Nearly a Posting Virtuoso
1,381 posts since Oct 2006
Reputation Points: 85
Solved Threads: 42
 

Hey, I asked the same thing yesterday! If you look a bit further down the board there’s a thread called 2d array of strings. You should find what you’re looking for there hopefully!

sirkraven
Newbie Poster
16 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You