is there a split function in c++?
e.g
_fstrcpy(data, split(data,1) );
or something, im not sure,
so if the var is
char Word[50] = "Hello im a programmer"
i want to try and split Word by the spaces, so split Word 2 maybe gives 'im' ?
Printable View
is there a split function in c++?
e.g
_fstrcpy(data, split(data,1) );
or something, im not sure,
so if the var is
char Word[50] = "Hello im a programmer"
i want to try and split Word by the spaces, so split Word 2 maybe gives 'im' ?
make use of find_first_of
Here you go try this
Quote:
#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;
int main()
{
char str[] = "Hello; im; a; programmer;";
char *StrPtr = NULL;
StrPtr = strtok( str, ";" );
while( StrPtr != NULL ) {
cout << StrPtr << endl;
StrPtr = strtok ( NULL, ";" );
}
system("PAUSE");
return 0;
}