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