#includechar *encrypt(char *string);
char *decrypt(char *string);
main()
{
char item[80];
char *point;
char *pEncrypted;
char *pDecrype;
printf("Please enter the string need to encrypt:\n");
gets(item);
point=item;
pEncrypted=encrypt(point);
printf("\nThe string after encrypted is:\n%s\n",pEncrypted);
pDecrype=decrypt(pEncrypted);
printf("\nThe string after decrypted is:\n%s\n",pDecrype);
free(pEncrypted);
free(pDecrype);
}
char *encrypt(char *string)
{
char *q,*t;
q=(char *)malloc(sizeof(char)*80);
if(!q)
{
printf("No place to malloc!");
return 0;
}
t=q;
while(*string!=\0)
{
*q=*string-2;
string++;
q++;
}
*q=\0;
return t;
}
char *decrypt(char *string)
{
char *q,*t;
q=(char *)malloc(sizeof(char)*80);
if(!q)
{
printf("No place to malloc!");
return 0;
}
t=q;
while(*string!=\0)
{
*q=*string+2;
string++;
q++;
}
*q=\0;
return t;
}