¡±Äã×ßÖ®áá¡°Ôõôͨ¹ýc/C++ת»»³É¡°Äã×ßÖ®ºó¡±
ááÕâ¸öºÃÏó²»ÊÇGBK£¬ÄǸÃʲô·½Ê½°Ñ¡±Äã×ßÖ®áᡰת»»³É¡°Äã×ßÖ®ºó¡±ÄØ£¿
×ö¸öÓ³Éä±í£¬¾ÍÏñbig5תgb2312Ò»Ñù
Õâ¸öÓ³Éä±íÄÇÀïÓÐÏ£¿
CSDNÏÂÔØÇøÓÐ
string Big2Gb(const string& sBig)
{
char* pszBig5=NULL; //Big5±àÂëµÄ×Ö·û
wchar_t* wszUnicode=NULL; //Unicode±àÂëµÄ×Ö·û
char* pszGbt=NULL; //Gb±àÂëµÄ·±Ìå×Ö·û
char* pszGbs=NULL; //Gb±àÂëµÄ¼òÌå×Ö·û
string sGb; //·µ»ØµÄ×Ö·û´®
int iLen=0; //ÐèҪת»»µÄ×Ö·ûÊý
pszBig5=const_cast <char*>(sBig.c_str()); //¶ÁÈëÐèҪת»»µÄ×Ö·û²ÎÊý
//¼ÆËãת»»µÄ×Ö·ûÊý
iLen=MultiByteToWideChar (950, 0, pszBig5, -1, NULL,0) ;
//¸øwszUnicode·ÖÅäÄÚ´æ
wszUnicode=new wchar_t[iLen+1];
//ת»»Big5Âëµ½UnicodeÂ룬ʹÓÃÁËAPIº¯ÊýMultiByteToWideChar
MultiByteToWideChar (950, 0, pszBig5, -1, wszUnicode,iLen);
//¼ÆËãת»»µÄ×Ö·ûÊý
iLen=WideCharToMultiByte (936, 0, (PWSTR) wszUnicode, -1, NULL,0, NULL, NULL) ;
//¸øpszGbt·ÖÅäÄÚ´æ
pszGbt=new char[iLen+1];
//¸øpszGbs·ÖÅäÄÚ´æ
pszGbs=new char[iLen+1];
//ת»»UnicodeÂëµ½GbÂë·±Ì壬ʹÓÃAPIº¯ÊýWideCharToMultiByte
WideCharToMultiByte (936, 0, (PWSTR) wszUnicode, -1, pszGbt,iLen, NULL, NULL) ;
//ת»»GbÂë·±Ìåµ½GbÂë¼òÌ壬ʹÓÃAPIº¯ÊýLCMapString
LCMapString(0x0804,LCMAP_SIMPLIFIED_CHINESE, pszGbt, -1, pszGbs, iLen);
//·µ»ØGbÂë¼òÌå×Ö·û
sGb=pszGbs; <
Ïà¹ØÎÊ´ð£º
C\C++ÈçºÎ¼ÆË㺯ÊýµÄµ¼Êý,±¾ÈËÐÂÊÖ£¬Ïëд¸ö³ÌÐò£¬µ«ÊDz»ÖªµÀÈçºÎÏÂÊÖ£¬»¹Íû¸ßÊÖÖ¸µãÒ»¶þ£¬Ð»¹ý¡£
Õâ¸ö¡¡
¸úº¯ÊýµÄ¾ßÌåÐÎʽÓйذɣ¬ÄѵÀÄãÏë±à³ö¸ö¡°ÍòÄÜ¡±µÄÇ󵼺¯Êý£¿
°³ÉÏѧʱÏë¹ý×Ô¶¯ÍƵ¼¹«Ê½£¬ºóÀ´ ......
ÎÊһϣº
#include <stdio.h>
int main()
{
char x, y, z;
int i;
int a[16];
for(i=0; i<=16; i++)
{
a[i] = 0;
......
'\108'×÷Ϊ×Ö·û³£Á¿¶Ô²»¶Ô£¿
תÒå×Ö·û'\ddd'±íʾ3λ8½øÖÆËù´ú±íµÄ×Ö·û¡£ µ«ÊÇ108²»ÊÇÕýÈ·µÄ8½øÖƱíʾ·½·¨£¬Òò´ËÓ¦¸ÃÊÇ´íÎóµÄ¡£
µ«ÊÇchar a='\108'; Ϊʲô±àÒë²»³ö´íÄØ£¿
\108 û³¬¹ý ......
¹¤×÷ÄÚÈÝ Ñз¢
×ʸñÒªÇó£º
211ºÍÖصãԺУ±¾¿Æ 3Ä깤×÷¾Ñé
211ºÍÖصãԺУ˶ʿ 1Ä깤×÷¾Ñé
ÆÕͨԺУÔÚ¹¤×÷ÄêÏÞÉϸ÷¼Ó1Äê
ÓÐͨÐÅÏà¹Ø¿ª·¢¾ÑéÕßÓÅÏÈ£¬µ±È»C/C++ »ù´¡ÒªÔúʵ
à ......
¶¨ÒåÁË
ifstream fin("in.txt");
±ÈÈçÎļþÊ×ÐÐÊÇÒ»¸öÊý×Ö£¬µÚ¶þÐÐÊÇÒ»´®×Ö·û¡£
int M;
char* str;
fin>>M;
fin>>str;
M¿ÉÒÔ¶Á³öÀ´£¬str×ÜÊÇÎÞ·¨¶ÁÈ ......