#include<stdio.h>
#include<string.h>
#define MAXLINE 100
void encrypt( char* );
void encrypt1(char s[]);
int main()
{
char line [MAXLINE];
printf("input the string: ");
gets(line); //字符数组是实参
encrypt(line);
printf("%s%s\n","after being encrypted:",line);
printf("input the string: ");
gets(line);
encrypt1(line);
printf("%s%s\n","after being encrypted:",line);
return 0;
}
//字符指针作为函数形参
void encrypt( char*s )
{
for(;*s!='\0';s++)
if(*s=='z')
*s='a';
else
*s=*s+1;
}
//字符数组作为函数形参
void encrypt1(char s[])//字符指针常量s相当于字符数组s[],*s是指向字符串首字符地址
{
int i;
for(i=0;s[i]!='\0';i++)
if(s[i]=='z')
s[i]='a';
else
s[i]=s[i]+1;
}