Need a project done?

C++ Programming Developer

Search This Blog

Tokenization in C++




#include <iostream>
using namespace std;

int main()
{
char a[10] = "He is ";
char b[10] ="good boy.";

cout << strtok(a," ") << endl;

return 0;
}











#include <iostream>
using namespace std;

int main()
{
char a[] = "He is good boy.";

cout << strtok(a," ") << endl;
cout << strtok(a," ") << endl;
return 0;
}



#include <iostream>
using namespace std;

int main()
{
char a[] = "He is good boy.";

cout << strtok(a," ") << endl;
cout << strtok(NULL," ") << endl;
return 0;
}









#include <iostream>
using namespace std;

int main()
{
char a[] = "He is good boy.";
char *p = a;

p = strtok(a," ");//Starting Tokenization.
while ( p != NULL)
{
cout << p << endl;
p = strtok(NULL," "); //Appends \0 after each tokenization.
}

return 0;
}



#include <iostream>
using namespace std;

int main()
{
char a[] = "He,is, good, boy.";
char *p = a;

p = strtok(a,",");//Starting Tokenization.
while ( p != NULL)
{
cout << p << endl;
p = strtok(NULL,","); //Appends \0 after each tokenization.
}

return 0;
}






"Don't let anyone ever make you feel like you don't deserve what you want."