array of strings

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2008
Posts: 19
Reputation: jmines is an unknown quantity at this point 
Solved Threads: 1
jmines jmines is offline Offline
Newbie Poster

array of strings

 
0
  #1
Apr 1st, 2008
I am trying to make an array of strings in C++. The problem is this that i need the strings to be multiline.
Is this possible in C++? how can we do it?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,378
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1466
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: array of strings

 
0
  #2
Apr 1st, 2008
This is no such concept as multi-line strings. If you want CR/LF in the string then just append "\n" whereever you want a new line to begin when output
  1. std::string hello = "Hello\nWorld\n";
  2. cout << hello;
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 19
Reputation: jmines is an unknown quantity at this point 
Solved Threads: 1
jmines jmines is offline Offline
Newbie Poster

Re: array of strings

 
0
  #3
Apr 1st, 2008
by multi-line i mean this concept
getline(cin, quiz, '$');

This will allow the user to enter strings composed of multiple lines. He can continue to enter strings (even if he presses enter) until he presses $.

now i want to make an array which can store this type of strings. Is it again not possible??
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,378
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1466
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: array of strings

 
0
  #4
Apr 1st, 2008
you mean something like this?
  1. std::vector<std::string> arr;
  2. std::string line;
  3.  
  4. while( getline(cin,line) && line[0] != '$')
  5. {
  6. arr.push_back(line);
  7. }

I hope you realize you can't enter "$1,000.00" with that
Last edited by Ancient Dragon; Apr 1st, 2008 at 11:01 am.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 19
Reputation: jmines is an unknown quantity at this point 
Solved Threads: 1
jmines jmines is offline Offline
Newbie Poster

Re: array of strings

 
0
  #5
Apr 1st, 2008
yes, i mean this thing.
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC