![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jan 2005
Posts: 21
Rep Power: 0
![]() |
stringstream delimiter
Is it possible to change the delimiter of a stringstream? For example,
#include<sstream>
#include<string>
int main(){
std::string s;
std::stringstream ss("A B C");
ss >> s;
}Then s is "A". Is it possible to make s be "A B C"? |
|
|
|
|
|
#2 |
|
Professional Programmer
|
__________________
JG-Webdesign |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Jan 2005
Posts: 21
Rep Power: 0
![]() |
Thanks, I know I can do it other way. But I still want to know whether I can do it within stringstream or not.
|
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Jun 2006
Location: Ireland
Posts: 152
Rep Power: 3
![]() |
Well the following will work:
#include<sstream>
#include<string>
int main(){
std::string s;
std::stringstream ss("A B C");
s = ss.str();
}
__________________
Visit my website BinaryNotions. |
|
|
|
|
|
#5 |
|
Professional Programmer
|
No he is looking for a way to split "A-B-C" or "A:B:C" using string streams.
__________________
JG-Webdesign |
|
|
|
|
|
#6 |
|
Hobbyist Programmer
Join Date: Jun 2006
Location: Ireland
Posts: 152
Rep Power: 3
![]() |
Not sure if that is what he wants, the post is very unclear.
Any-hoo this link might be useful: skipws / noskipws
__________________
Visit my website BinaryNotions. |
|
|
|
|
|
#7 | |
|
Newbie
Join Date: Jan 2005
Posts: 21
Rep Power: 0
![]() |
Quote:
After some googling and searching in my books, it seems that there is no way to do it just by using the operator >> . Anyone could confirm this? |
|
|
|
|
|
|
#8 | |
|
Newbie
Join Date: Jan 2005
Posts: 21
Rep Power: 0
![]() |
Quote:
|
|
|
|
|
|
|
#9 |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 763
Rep Power: 3
![]() |
I think stringstream extends iostream, so you should be able to use the getline function, which allows you to set a delimiter.
__________________
<insert disclaimer here> <insert shameless plug for Visual Studio here> |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Unicode & ANSI support w/ string & stringstream | Cache | C++ | 0 | May 9th, 2006 6:34 PM |
| stringstream expects a space at the end of input? | InfoGeek | C++ | 5 | Apr 29th, 2006 7:46 AM |
| Remove last char from a stringstream | yOURsELF | C++ | 10 | Mar 24th, 2006 5:23 PM |
| stringstream | Ancient Dragon | C++ | 12 | Jun 3rd, 2005 4:50 PM |
| Delimiter Fun | Supadude | Java | 5 | Jan 16th, 2005 11:41 PM |