#include <stdio.h>
#include <string.h>
void main()
{
char str[100] = {"This is a CString!"};
char str1[100];
char str2[100] = {"Here is a demo!"};
char *pstr;
printf("%s\n", str);
strcpy(str1,str);
printf("%s\n", str1);
printf("%d\n", strlen(str1));
strcat(str1,str2);
printf("%s\n", str1);
puts(str1);
printf("%d\n",strcmp(str,str));
printf("%d\n",strcmp(str1,str));
pstr = strstr(str, "CString");
printf("%s\n",pstr);
getchar();
}
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;
void main()
{
string str = "Please split this phrase into tokens";
cout<<str<<endl;
char *cstr = new char [str.size()+sizeof(char)];
strcpy(cstr, str.c_str());
char *p;
p = strtok(cstr, " ");
while(p!=NULL)
{
cout<<p<<endl;
p = strtok(NULL, " ");
}
getchar();
}