[ create a new paste ] login | about

Link: http://codepad.org/D7Qni6iu    [ raw code | output | fork ]

C++, pasted on Feb 18:
#include <string.h>
#include <stdio.h>
int main()
{

char str[] ="now  #  is  the  time  for  all  #  good  men  to  come  to  the  #  aid  of  their  country";
	char strTemp[100]="";
	printf("str is %s\n",str);
	strcpy(strTemp,str);
	printf("str=%d\n",(int)str);
	printf("strTemp=%d\n",(int)strTemp);
	printf("tempstr is %s\n",strTemp);
	char delims[] = "#";
	char* result = NULL;
	result = strtok(strTemp,delims);
	while(result != NULL)
	{
		printf("result is \"%s\"\n",result);
		printf("tempstr is %s\n",strTemp);
		result = strtok(NULL,delims);
	}
	printf("str=%d\n",(int)str);
	printf("str is %s\n",str);
return 0;
}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
str is now  #  is  the  time  for  all  #  good  men  to  come  to  the  #  aid  of  their  country
str=-1081640247
strTemp=-1081640347
tempstr is now  #  is  the  time  for  all  #  good  men  to  come  to  the  #  aid  of  their  country
result is "now  "
tempstr is now  
result is "  is  the  time  for  all  "
tempstr is now  
result is "  good  men  to  come  to  the  "
tempstr is now  
result is "  aid  of  their  country"
tempstr is now  
str=-1081640247
str is now  #  is  the  time  for  all  #  good  men  to  come  to  the  #  aid  of  their  country


Create a new paste based on this one


Comments: