C/C++/VC MFC char & int study
²âÊÔ´úÂëÒ»£¨VC6.0¡¢C-code£©£º
#include <stdio.h>
void main()
{
int aa;
unsigned char j1,j2;
aa=j1=j2=0;
aa=49;
j1=aa;
printf("j1=%d \n",j1);
j2=aa;
printf("j2=%c \n",j2);
}
¡¾·ÖÎö¡¿£º
[1]ÕýÈçËùÏëÏóµÄÊä³ö½á¹û£º
j1=49
j2=1
Press any key to continue
[2]ÏÈ˵Ã÷aaÔÚÄÚ´æÖеĴ洢ÐÎʽ£º0x0031£»
[3]j1 ,j2ͬΪunsigned charÐÍÊý¾Ý£»
[4]ÉÏÊö¶þ±äÁ¿Êä³ö½á¹û²»Ò»Ö£»ÓÉprinf£¨£©º¯ÊýÖеĸñʽ·û²»Í¬ËùÖ£»
[5]ÕâÀïÈÏΪ£ºÆäÒ»£¬¶ÔÓÚ %d¸ñʽ·û£¬pintf()ÄÜ“ÕýÈ·”·´Ó³ j1 Öд洢µÄÊý¾Ý£»
Æä¶þ£¬¶ÔÓÚ %c¸ñʽ·û£¬printf() È´²»ÄÜ“ÕýÈ·”·´Ó³ j2(==aa)Öд洢µÄ¶þ½øÖÆÊý¾Ý¡£
[6]¶ÔÓÚÒÔÉÏ·ÖÎöµÄÀí½â£ºÏÔÈ»£¬printf()º¯Êý½«»áÒÀÕÕÓû§Ìṩ¸øËüµÄ ¸ñʽ·û ¶Ô´ýÊä³öµÄÊý¾Ý½øÐÐ
“´¦À픺ó£¬Êä³öÖÁÏÔʾÉ豸ÉÏ¡£
[7]……
²âÊÔ´úÂë¶þ(VC6.0 ,VC mfc)£º
int aa,bb;
aa=bb=0;
CString strtemp,display;
strtemp.Format("%c",170); //170==0xAA
MessageBox(strtemp);
int length=strtemp.GetLength();
for(int i=0;i<length;i++)
{
aa+=strtemp.GetAt(i);
bb+=(unsigned char)strtemp.GetAt(i);
}
display.Format("(TCHAR)aa=%x",aa);
MessageBox(display);
display.Format("(unsigned char)bb=%x",bb);
MessageBox(display);
¡¾·ÖÎö¡¿£º
[1]Êä³öÇåµ¥ÈçÏ£º
MessageBox(strtemp);===== "?"
display.Format("(TCHAR)aa=%x",aa);
MessageBox(display);====="(TCHAR)aa=ffffffaa" //(ff ff ff aa)
display.Format("(unsigned char)bb=%x",bb);
MessageBox(display);====="("(unsigned char)bb=aa"
[2] // return single character at zero-based index
TCHAR GetAt(int nIndex) const;
<À´Ô´£ºCString-class£»×îÖÕ½âÊÍΪmicrosoft VC6.0>
[3]typedef char TCHAR, *PT
Ïà¹ØÎĵµ£º
c/sÊÇ¿Í»§¶ËºÍ·þÎñÆ÷£¬b/sÊÇä¯ÀÀÆ÷ºÍ·þÎñÆ÷¡£
c/sÔÚ¿Í»§¶ËÒª°²×°Èí¼þµÄ£¬b/sÖ»ÒªÓÐIE¾Í¿ÉÒÔä¯ÀÀ¡£
c/sµÄÀ©Õ¹Éý¼¶±È½ÏÀ§ÄÑ£¬b/s¾ÍºÜÈÝÒ׵ġ£
c/sµÄ°²È«ÐÔºÃһЩ£¬b/s¾ÍûÓÐc/sµÄ¸ß¡£
c/sÒ»°ãÓÃÔÚ¾ÖÓòÍø£¬b/sÒ»°ãÓÃÔÚ¹ãÓòÍø¡£
------------------------------------------------
C/SÔËÓÃÔÚÓÐרÓÃÐԵij¡ºÏ¡£±ÈÈç ......
1.fopen()
¡¡¡¡fopenµÄÔÐÍÊÇ£ºFILE *fopen(const char
*filename,const char
*mode)£¬fopenʵÏÖÈý¸ö¹¦ÄÜ£ºÎªÊ¹Óöø´ò¿ªÒ»¸öÁ÷£¬°ÑÒ»¸öÎļþºÍ´ËÁ÷ÏàÁ¬½Ó£¬¸ø´ËÁ÷·µ»ØÒ»¸öFILRÖ¸Õë¡£
¡¡¡¡²ÎÊýfilenameÖ¸ÏòÒª´ò¿ªµÄÎļþÃû£¬mode±íʾ´ò¿ª×´Ì¬µÄ×Ö·û´®£¬Æä
È¡ÖµÈçÏ£º
¡¡¡¡×Ö·û´® º¬Òå
¡¡¡¡"r" ÒÔÖ»¶Á·½Ê½´ò¿ª ......
ÓÐ¹Ø extern "C"
¸ã¹ýCºÍC++»ì±àµÄͬ־ÃǶ¼ÖªµÀÕâ¸öɶÒâ˼¡£
Õâ¶ùÓн²£ºhttp://www.cppblog.com/Macaulish/archive/2008/06/17/53689.html
µ«¿´Ò»ÏÂÏÂÃæµÄÕâ¸ö´úÂ룺
#include <iostream>
using namespace
std;
extern "C" { int g_inta; }
int main (void)
{
g_ ......
1.·Ö²ãÉè¼Æ£¬¸ôÀëƽ̨Ïà¹ØµÄ´úÂë¡£¾ÍÏñ¿É²âÊÔÐÔÒ»Ñù£¬¿ÉÒÆÖ²ÐÔÒ²Òª´ÓÉè¼Æ×¥Æð¡£Ò»°ãÀ´Ëµ£¬×îÉϲãºÍ×îϲ㶼²»¾ßÓÐÁ¼ºÃµÄ¿ÉÒÆÖ²ÐÔ¡£×îÉϲãÊÇGUI£¬´ó¶àÊýGUI¶¼²»ÊÇ¿çƽ̨µÄ£¬ÈçWin32 SDKºÍMFC¡£×îϲãÊDzÙ×÷ϵͳAPI£¬´ó¶à²¿·Ö²Ù×÷ϵͳAPI¶¼ÊÇרÓõġ£
¡¡¡¡Èç¹ûÕâÁ½²ãµÄ´úÂëÉ¢²¼ÔÚÕû¸öÈí¼þÖУ¬ÄÇôÕâ¸öÈí¼þµÄ¿ÉÖ²ÐÔ½«·Ç³£µÄ² ......
C/S¼Ü¹¹µÄÓŵãÈçÏ£º
£¨1£©C/S¼Ü¹¹µÄ½çÃæºÍ²Ù×÷ÊÖÊÆ¿ÉÒÔËæ×Å¿Í»§µÄÒªÇó½øÐж¨ÖÆ£¬¿ÉÒÔʵÏֵķdz£Æ¯ÁÁ£¬ÓÉÓÚÅÖ¿Í»§¶Ë½¨Á¢ÔÚÓ¦ÓõĻù´¡ÉÏ£¬Òò´Ë²»»áÓÉÓÚƯÁÁµÄ½çÃæ¶øÓ°Ïìʵ¼ÊµÄ²Ù×÷¡£
£¨2£©ÏµÍ³°²È«ÐÔÄÜ¿ÉÒԵõ½ºÜºÃµÄ±£Ö¤£¬ÊµÏÖ¶à²ãÈÏÖ¤Ò²²»À§ÄÑ¡£
£¨3£©C/S½á¹¹µÄϵͳÓÉÓÚÖ»ÓÐÒ»²ã½»»¥£¬Òò´ËÏìÓ¦Ëٶȷdz£¿ì¡£
C/S¹¹¼ÜµÄÈ ......