请问用c语言怎么计算校验和?能将带有汉字的文件读入然后计算?过程怎么写!好着急啊!
文件不管有没有汉字,都当作二进制数据。校验和还分为不同位数的。
具体要看对方协议的要求
仅供参考:http://download.csdn.net/detail/captain_black/679608
中文字符串可以使用printf()、puts()等函数直接输出。
#include
#include
int main()
{
const char str[] = "这里全是中文";
printf("\n输出字符数:%d\n", printf(str));
puts(str);
return 0;
}
2、单个中文字符,需要进行本地化设置,需要使用宽字符版的printf()即wprintf输出。
#include
#include
int main()
{
setlocale(LC_ALL, "chs");
wchar_t wc = L'中';
wprintf(L"%c\n",wc);
return 0;
}