大家好我在网上下载了个获取汉字笔画的CPP文件请问如何把它加入到VC工程中呢static int gb2312_stroke_count[] =
{
/* B0 */
10, 7, 10, 10, 8, 10, 9, 11,
17, 14, 13, 5, 13, 10, 12, 15,
10, 6, 10, 9, 13, 8, 10, 10,
8, 8, 10, 5, 10, 14, 16, 9,
12, 12, 15, 15, 7, 10, 5, 5,
7, 10, 2, 9, 4, 8, 12, 13,
。。
。。
/* F7 */
18, 18, 18, 18, 18, 19, 19, 19,
19, 19, 19, 20, 20, 20, 21, 14,
14, 15, 15, 16, 18, 18, 18, 19,
19, 13, 13, 14, 14, 14, 15, 15,
17, 17, 18, 18, 19, 19, 22, 14,
14, 15, 16, 16, 17, 19, 12, 15,
18, 22, 22, 10, 13, 14, 15, 15,
16, 16, 16, 18, 19, 20, 23, 25,
14, 15, 17, 13, 16, 16, 17, 19,
19, 21, 23, 17, 17, 17, 18, 18,
19, 20, 20, 20, 20, 21, 17, 18,
20, 23, 23, 16, 17, 23,
/* F8 */
};
//-------------------------------------------------------------------
int GetGB2312StrokeCount(unsigned char c1, unsigned char c2)
{
unsigned offset; if ( c1 < 0xB0 || c1 > 0xF7 || c2 < 0xA1 || c2 > 0xFE )
{
// not a valid gb2312 Chinese character
return -1;
}
offset = ((unsigned)c1-0xB0) * (0xFE-0xA0) + ((unsigned)c2-0xA1);
return gb2312_stroke_count[offset];
}
//--------------------------------------------------------------------
#include <iostream>
#include <string>
using namespace std;void main()
{
char str[256];
while(1)
{
cin>>str;
cout<<"笔画数为: ";
for ( unsigned i=0; i<strlen(str); i+=2 )
{
cout<< GetGB2312StrokeCount(str[i], str[i+1])<<" ";
}
cout<<endl;
}}
//-------------------------------------------------------------
其中的int GetGB2312StrokeCount(unsigned char c1, unsigned char c2)
应该如何传递参数呢,我试过
str[0]='我';
但是不行啊
请高手帮帮忙吧
{
/* B0 */
10, 7, 10, 10, 8, 10, 9, 11,
17, 14, 13, 5, 13, 10, 12, 15,
10, 6, 10, 9, 13, 8, 10, 10,
8, 8, 10, 5, 10, 14, 16, 9,
12, 12, 15, 15, 7, 10, 5, 5,
7, 10, 2, 9, 4, 8, 12, 13,
。。
。。
/* F7 */
18, 18, 18, 18, 18, 19, 19, 19,
19, 19, 19, 20, 20, 20, 21, 14,
14, 15, 15, 16, 18, 18, 18, 19,
19, 13, 13, 14, 14, 14, 15, 15,
17, 17, 18, 18, 19, 19, 22, 14,
14, 15, 16, 16, 17, 19, 12, 15,
18, 22, 22, 10, 13, 14, 15, 15,
16, 16, 16, 18, 19, 20, 23, 25,
14, 15, 17, 13, 16, 16, 17, 19,
19, 21, 23, 17, 17, 17, 18, 18,
19, 20, 20, 20, 20, 21, 17, 18,
20, 23, 23, 16, 17, 23,
/* F8 */
};
//-------------------------------------------------------------------
int GetGB2312StrokeCount(unsigned char c1, unsigned char c2)
{
unsigned offset; if ( c1 < 0xB0 || c1 > 0xF7 || c2 < 0xA1 || c2 > 0xFE )
{
// not a valid gb2312 Chinese character
return -1;
}
offset = ((unsigned)c1-0xB0) * (0xFE-0xA0) + ((unsigned)c2-0xA1);
return gb2312_stroke_count[offset];
}
//--------------------------------------------------------------------
#include <iostream>
#include <string>
using namespace std;void main()
{
char str[256];
while(1)
{
cin>>str;
cout<<"笔画数为: ";
for ( unsigned i=0; i<strlen(str); i+=2 )
{
cout<< GetGB2312StrokeCount(str[i], str[i+1])<<" ";
}
cout<<endl;
}}
//-------------------------------------------------------------
其中的int GetGB2312StrokeCount(unsigned char c1, unsigned char c2)
应该如何传递参数呢,我试过
str[0]='我';
但是不行啊
请高手帮帮忙吧
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货