c字符串替换strstr strncpy

#include <stdio.h> 
#include <string.h>

int main () 
{ 
char str[] ="This is a simple string"; 
char * pch; 
pch = strstr (str,"simple"); 
puts(pch); 
strncpy (pch,"sample",6); 
puts(pch); 
puts (str); 
return 0; 
}

结果:This is a sample string

posted on 2012-11-12 22:49  狼爱上羊  阅读(5451)  评论(0编辑  收藏  举报

导航