#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <pthread.h>
#include <semaphore.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
static char pstring[] = "Hello
"; // 这里不能是char*
int main()
{
char tmp ;
char* pstr = strchr(pstring,'l');
printf("pstr is %s %p
",pstr,pstr);
#if 0
// 搜后面的
pstr = strchr(pstr+1,'l'); // 是strchr不是strstr
printf("next pastr is %s
",pstr);
#endif //
//需要He
tmp = *pstr;
printf("%c",tmp);
pstr[0] = ' ';
printf("length is %d
",strlen(pstring)+1);
char* data = (char*)malloc(strlen(pstring)+1);
if(data == NULL)
{
printf("malloc failure
");
return -1;
}
printf("length is %d
",strlen(pstring)+1);
strcpy(data,pstring);
printf("data is %s
",data);
*pstr = tmp;
free(data);
while(1);
return 0;
}
