anyone have a way to take a string of unknown length and break it up using the spaces (white space) that are in it?
data example: president john jones, iii
Printable View
anyone have a way to take a string of unknown length and break it up using the spaces (white space) that are in it?
data example: president john jones, iii
look at tokenising function, strtok(...) I think in <cstring>/<string.h>
Using the CString class would be the easiest way.
http://msdn.microsoft.com/library/de.../cstring_1.asp
Quote:
anyone have a way to take a string of unknown length and break it up using the spaces (white space) that are in it?
data example: president john jones, iii
Code:#include <sstream>
#include <iostream>
#include <string>
using namespace std;
int main()
{
istringstream text("president john jones, iii");
string word;
while(text >> word)
cout << word << '\n';
}
I believe CString is only available in MFC, or otherwise difficult to get.Quote:
Originally posted by Dual-Catfish
Using the CString class would be the easiest way.
http://msdn.microsoft.com/library/de.../cstring_1.asp
Are you sure? I think you can either include cstring.h or windows.h and use it..
I don't see how you'd need MFC to use it..