//编写库函数stract实现数组的复制
void strcat1 (char *a,char *s)
{
while(*a++)
;
*a--;//覆盖0
while(*a++=*s++)
;
}
////编写一个函数,它能测出一个字符串的长度,函数返回值就是字符串的长度;
int find(char c)
{
int sum=0;
while(c=getchar() != '/n')
sum++;
return sum;
}
//利用递归函数调用方式,将所输入的5个字符,以相反顺序打印出来。
#include "stdio.h"
main()
{
int i=5;
void palin(int n);
palin(i);//调用函数,完成一定的功能
printf("/n");//输出
}
void palin(n)
int n;
{
char next;//定义一个最后的 变量
if(n<=1)//如果小于1的话
{
next=getchar();//
putchar(next);
}
else//如果不是的话
{
next=getchar();//将输入的数给最后一个变量
palin(n-1);//递归调用自身
putchar(next);
}
}
//编写函数fun,函数的功能是:从字符串中删除指定的字符。
#include "stdio.h"
int fun(char s[],int c)
{
char *q=s;
for(; *q; q++)//用指针开始移位
{
if(*q != c)
*(s++)=*q;
}
*s=0;
return *s;
}
main()
{
char ch;
static char str[]="Visual basic and visual c++";
printf("原始字符串:%s/n", str);
printf("输入一个字符:");
scanf("%c",&ch);
fun(str,ch);
printf("str[]=%s/n",str);
}