#include<stdio.h>
#include<string.h>
char head_tail(char str,char result){
int i = 0;
while(str != ‘h’){
str++;
}
if(str==‘h’&&(str+1)==‘e’&&(str+2)==‘a’&&(str+3)==‘d’){
while((str+i+3)!=’\0’){
(result+i)=(str+i+3);
i++;
printf("%d ",i); //循环多少次
}
}
}
int main(){
char str[100]={0};
char result[100]={0};
printf(“请输入一串字符:\n”);
gets(str);
printf(“头帧:head\n”);
printf(“尾帧:tail\n”);
head_tail(str,result);
printf(“取出的中间字符串=%s\n”,result);
return 0;
}
帧头帧尾代码
最新推荐文章于 2023-06-15 17:20:47 发布
本文介绍了一个使用C语言处理字符串的示例程序,该程序能够从输入的字符串中提取出以head开始的部分,并将其存储到另一个字符串变量中。通过遍历和条件判断,实现了对特定子串的定位和提取。
409

被折叠的 条评论
为什么被折叠?



