#include "stdafx.h"   char *fnFCS(const char *pstr,int iCount,char *pFCS)    //定義FCS校驗函數 {   if(pstr==NULL||pFCS==NULL)       //如果指針為null return NULL;           //返回NULL char ch=*pstr;          //定義字符變量并賦初值 for(int i=1;i<iCount;i++)        //循環iCount次 {     ch^=*(pstr+i);         //異或運算 }   char ct=ch>>4;            //取異或結果的高四位 if(ct>9)            //轉為ASCII碼 ct+='A'-10;            else    ct+='0';  *pFCS=ct; ct=ch&0x0F;           //取異或結果的低四位 if(ct>9)             //轉為ASCII碼 ct+='A'-10;  else    ct+='0';   *(pFCS+1)=ct;    return pFCS;           //返回校驗值 }    int main(int argc, char* argv[])       //定義主函數 {  char c,str[100]="";         //定義變量  int i=0;           //定義變量  char jyTemp[2];         //定義變量  printf("請輸入要校驗的字符串:\n");     //要求輸入字符串   while((str=getchar())!='\n')       //輸入字符串,直到遇到回車符  {   i+=1;   fnFCS(str,i,&jyTemp[0]);      //調用FCS計算函數  }   printf("以上字符串的FCS校驗是:'%c%c'。\n",jyTemp[0],jyTemp[1]);  //輸出結果  return 0; }