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

Member Avatar for GreenDay2001

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];
}

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.