c判断汉字
#include <windows.h>
int IsGB(PTSTR pText);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szText[] = {TEXT ("i服,了。uy")} ;
PTSTR pText;
int i;
unsigned char sqChar[20];
pText=szText;
while (*pText != '\0')
{
i=IsGB(pText);
switch(i)
{
case 0:
pText++;
MessageBox (NULL, TEXT ("发现数字、英文字符或英文标点"), TEXT ("Hello"), 0);
break;
case 1:
pText++;
pText++;
MessageBox (NULL, TEXT ("发现全角字符"), TEXT ("Hello"), 0);
break;
case 2:
pText++;
pText++;
MessageBox (NULL, TEXT ("发现汉字"), TEXT ("Hello"), 0);
break;
}
}
return 0 ;
}
int IsGB(PTSTR pText)
{
unsigned char sqChar[20];
sqChar[0]=*pText;
if (sqChar[0]>=0xa1)
if (sqChar[0]==0xa3)
return 1; //全角字符
else
return 2; //汉字
else
return 0; //英文、数字、英文标点
}
相关文档:
Boss说,要看OpenGL,看了快一个月,总算出了个像样的东西,用C写了个3D迷宫,
虽然只有350行
代码,不过边学边写,足足写了一周时间,还是小有成就感的,活活活!
&n ......
1.c++的到处函数只要在函数申明的时候加个导出关键字就可以了
2.参数类型问题,
一般的c++中char * 对应 c#中的string
而c++中 char **类型的参数对应c#中 ref string 这种一般都是用来返回字符串的!
3.函数入口问题,一般会出现 "找不到入口点" 这个问题不是由你引起的,而是系统自己把名字改了,改成什么样的名字建议你用 ......
DllImport所在的名字空间 using System.Runtime.InteropServices;
[DllImport("User32.dll")]
public extern static System.IntPtr GetDC(System.IntPtr hWnd);
private void button19_Click(obj ......
当要交换两个数的值时,通常的做法是定义一个临时变量,然后再进行交换。那么能不能不用临时变量而交换两个数的值呢?可以的!C语言提供的异或运算就可以实现这样的操作。
异或运算符^也称XOR运算符,它的规则是若参加运算的两个二进位同号,则结果为0(假);异号为1(真)。即0 ^ 0 = 0, 0 ^ 1 = 1, 1 ^ 0 = 1, ......
http://www.ddj.com/cpp/221600722
Q: HOW DO I... put timers with default actions in my C code?
A: Many times, we need to write programs that will only wait a certain specified amount of time for a user to do something. After that time, we need to assume that the user isn't going to do anything and ......