C 语言详解 之 字符串后缀
来源:互联网 发布:中航804知乎 编辑:程序博客网 时间:2024/06/05 09:25
#include <stdio.h>
#include <string.h>
#define MAX 100
int main()
{
char str1[MAX],str2[MAX];
printf("please input a string:/n");
scanf("%s",str1);
printf("please input another string:/n");
scanf("%s",str2);
int len1 = strlen(str1);
int len2 = strlen(str2);
int len = len1>len2?len2:len1;
for(int i=1;i<len;i++)
{
char temp1[MAX],tem2[MAX];
strncpy(temp1, &str1[len1-i],i);
temp1[i]='/0';
strncpy(temp2, &str2[len2-i],i);
temp2[i]='/0';
if(0 != strcmp(temp1,temp2))
break;
}
char str3[MAX];
strncpy(str3, &str1[len1-i+1],i-1);
str3[i-1]='/0';
printf("%s",str3);
return 0;
}
- C 语言详解 之 字符串后缀
- C语言字符串详解
- C语言之字符串
- C语言之字符串
- C语言之字符串
- C语言之字符串
- C语言之字符串
- C语言之字符串
- c语言之字符串
- C语言之字符串
- C语言之字符串
- c语言字符串函数详解
- C语言字符串函数详解
- c语言字符串函数详解
- c语言字符串函数详解
- c语言字符串函数详解
- C语言字符串函数详解
- c语言字符串函数详解
- 关于需求变更因素的调查,请大家支持!
- mysql使用基础
- Effective java学习笔记
- 窗体间数据传递
- linux跟踪利器之Ftrace
- C 语言详解 之 字符串后缀
- typedef struct与struct的区别
- 读C++Primer所得.2
- 常见文件、目录、路径操作函数
- 组合的递归算法
- ZJUT1632 搭积木 ZJUT1278 最多拦截导弹数 LIS
- perl ibm相关经典文档集合链接
- 2011年2月15日到福州
- LINUX+APACHE+PHP+BDB+OPENLDAP+PHPLDAPADMIN安装配置