c语言next的用法,C语言strchr使用之Next查找和截断想要的字符串
#include
#include
#include
#include
#include
#include
#include
#include
static char pstring[] = "Hello\n"; // 這里不能是char*
int main()
{
char tmp ;
char* pstr = strchr(pstring,‘l‘);
printf("pstr is %s %p\n",pstr,pstr);
#if 0
// 搜后面的
pstr = strchr(pstr+1,‘l‘); // 是strchr不是strstr
printf("next pastr is %s\n",pstr);
#endif //
//需要He
tmp = *pstr;
printf("%c",tmp);
pstr[0] = ‘\0‘;
printf("length is %d\n",strlen(pstring)+1);
char* data = (char*)malloc(strlen(pstring)+1);
if(data == NULL)
{
printf("malloc failure\n");
return -1;
}
printf("length is %d\n",strlen(pstring)+1);
strcpy(data,pstring);
printf("data is %s\n",data);
*pstr = tmp;
free(data);
while(1);
return 0;
}
原文:https://www.cnblogs.com/nowroot/p/13660647.html
總結(jié)
以上是生活随笔為你收集整理的c语言next的用法,C语言strchr使用之Next查找和截断想要的字符串的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 在分期乐软件中如何开通乐花卡
- 下一篇: 开发板实现645协议C语言,迅为-imx