#include
#include
unsigned char Encrypt(unsigned char cKey,unsigned char cCode)
{
unsigned char sKey;
sKey=cKey^cCode;
return(sKey);
}
unsigned char prog8_2()
{
unsigned char Encrypt(unsigned char cKey,unsigned char cCode);
unsigned char cha,chz,chr;
scanf("%c,%c",&cha,&chz);//此處出錯c(14) : error C2059: syntax error : 'type'
chr=unsigned char Encrypt(cha,chz);
printf("%r",chr);
return 0;
}
void main()
{
prog8_2();
}
#include<stdio.h>
unsigned char Encrypt(unsigned char cKey,unsigned char cCode)
{
/*
假設你輸入的是1,2,那麼ckey就是0x31,cCode是0x32
0011 0001
^ 0011 0010
-----------
0000 0011
故sKey就是0x03,輸出格式是%d,則輸出3,輸入格式是%c,則輸出0x03對應得ascii字符
*/
unsigned char sKey;
sKey = cKey ^ cCode;
return (sKey);
}
unsigned char prog8_2()
{
//這裡不用寫,不要在一個函數內聲明另一個函數
//unsigned char Encrypt(unsigned char cKey,unsigned char cCode);
unsigned char cha,chz,chr;
//最好加一個提示信息
printf("請輸入數據:");
//輸入數據的時候注意也得輸入','
scanf("%c,%c",&cha,&chz);
//使用函數的時候直接使用函數名就行,不用添加函數類型
chr = Encrypt(cha,chz);//出錯信息指示的是這裡,而並不是上一句,此處出錯c(14) : error C2059: syntax error : 'type'
//這裡不是r
printf("%d\n",chr);//或者%c
return 0;
}
void main()
{
prog8_2();
}