how to read an array of strings in C++

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2007
Posts: 59
Reputation: Gaurav arora is an unknown quantity at this point 
Solved Threads: 0
Gaurav arora Gaurav arora is offline Offline
Junior Poster in Training

how to read an array of strings in C++

 
0
  #1
Apr 12th, 2007
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
  1. for(i=0;i<m;i++)
  2. for(j=0;j<n;j++)
  3. 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
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 1,311
Reputation: vishesh is on a distinguished road 
Solved Threads: 36
vishesh's Avatar
vishesh vishesh is offline Offline
Nearly a Posting Virtuoso

Re: how to read an array of strings in C++

 
0
  #2
Apr 12th, 2007
No need to that a way.
Here's how you could do that:

  1. char str[5][50];
  2. for(int i=0; i<5; i++)
  3. {
  4. cin >> str[i];
  5. }
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 16
Reputation: sirkraven is an unknown quantity at this point 
Solved Threads: 0
sirkraven sirkraven is offline Offline
Newbie Poster

Re: how to read an array of strings in C++

 
0
  #3
Apr 12th, 2007
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!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 3227 | Replies: 2
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC