主要是没接触过啊。
说说原理也行啊。目前只见过输出中文的,没见过读取,存储,处理中文的。
说说原理也行啊。目前只见过输出中文的,没见过读取,存储,处理中文的。

代码测试环境: WinXP+C-Free5.0.
程序代码:
#include <clocale>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <conio.h>
const wchar_t* NumberList = L"零一二三四五六七八九";
int ChineseToInteger(const wchar_t* str, const wchar_t* const numList);
int wmain(void)
{
const wchar_t* str1 = L"一四零零六";
const wchar_t* str2 = L"二五七";
_wsetlocale(LC_ALL, L"chs");
wprintf_s(L"%s -> %d\n", str1, ChineseToInteger(str1, NumberList));
wprintf_s(L"%s -> %d\n", str2, ChineseToInteger(str2, NumberList));
wprintf_s(L"\nPress any key to continue...");
_getwch();
return EXIT_SUCCESS;
}
int ChineseToInteger(const wchar_t* str, const wchar_t* const numList)
{
int ret_value = 0;
for (int counter = 0; *str != L'\0'; ++str, ++counter)
{
ret_value = ret_value * 10 + wcschr(NumberList, *str) - NumberList;
}
return ret_value;
}
