I have "hello i am fine" as a single string.I want to store hello,i,am,fine in separate variables.How do i do that.Please help me
Substring in C++
Collapse
X
-
Try to use strstream in C++ stl for this.Originally posted by aramakriI have "hello i am fine" as a single string.I want to store hello,i,am,fine in separate variables.How do i do that.Please help me
You can achieve what you want
Thanks
Raghuram -
then you have to go for C library the strtok function.Originally posted by aramakriAny other way to do it Raghu instead of strstream stl
I cant remember any other way in c++
Thanks
RaghuramComment
-
You are supposed to use stringstream in C++ for this.Originally posted by aramakriAny other way to do it Raghu instead of strstream stl
You can't use the C strtok because a) it only works for C strings and b) prevents your code from being multithreaded.
The entire C strings library is depreacated in C++. It is supported by C++ compilers only so ancient code can still compile but you are not to write new code using this obsolete library.Comment
Comment