Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¡±Äã×ßÖ®áá¡°Ôõôͨ¹ý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++ÈçºÎ¼ÆË㺯ÊýµÄµ¼Êý

C\C++ÈçºÎ¼ÆË㺯ÊýµÄµ¼Êý,±¾ÈËÐÂÊÖ£¬Ïëд¸ö³ÌÐò£¬µ«ÊDz»ÖªµÀÈçºÎÏÂÊÖ£¬»¹Íû¸ßÊÖÖ¸µãÒ»¶þ£¬Ð»¹ý¡£
Õâ¸ö¡­¡­

¸úº¯ÊýµÄ¾ßÌåÐÎʽÓйذɣ¬ÄѵÀÄãÏë±à³ö¸ö¡°ÍòÄÜ¡±µÄÇ󵼺¯Êý£¿

°³ÉÏѧʱÏë¹ý×Ô¶¯ÍƵ¼¹«Ê½£¬ºóÀ´ ......

C ³ÌÐòÎÊÌâ (¶þ) - C/C++ / CÓïÑÔ

ÎÊһϣº
#include <stdio.h>
int main()
{
  char x, y, z;
  int i;
  int a[16];
  for(i=0; i<=16; i++)
  {
  a[i] = 0;
  ......

cÖеÄתÒå×Ö·ûÎÊÌâ

    '\108'×÷Ϊ×Ö·û³£Á¿¶Ô²»¶Ô£¿
תÒå×Ö·û'\ddd'±íʾ3λ8½øÖÆËù´ú±íµÄ×Ö·û¡£ µ«ÊÇ108²»ÊÇÕýÈ·µÄ8½øÖƱíʾ·½·¨£¬Òò´ËÓ¦¸ÃÊÇ´íÎóµÄ¡£
µ«ÊÇchar a='\108'; Ϊʲô±àÒë²»³ö´íÄØ£¿
\108 û³¬¹ý ......

ÄϾ© ÖÐÐË C³ÌÐòÔ±ÕÐƸ

¹¤×÷ÄÚÈÝ Ñз¢

×ʸñÒªÇó£º
211ºÍÖصãԺУ±¾¿Æ 3Ä깤×÷¾­Ñé
211ºÍÖصãԺУ˶ʿ 1Ä깤×÷¾­Ñé

ÆÕͨԺУÔÚ¹¤×÷ÄêÏÞÉϸ÷¼Ó1Äê


ÓÐͨÐÅÏà¹Ø¿ª·¢¾­ÑéÕßÓÅÏÈ£¬µ±È»C/C++ »ù´¡ÒªÔúʵ

à ......

´ÓÎļþ¶ÁC´®µÄÎÊÌâ

¶¨ÒåÁË

ifstream fin("in.txt");

±ÈÈçÎļþÊ×ÐÐÊÇÒ»¸öÊý×Ö£¬µÚ¶þÐÐÊÇÒ»´®×Ö·û¡£

int M;
char* str;

fin>>M;
fin>>str;

M¿ÉÒÔ¶Á³öÀ´£¬str×ÜÊÇÎÞ·¨¶ÁÈ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ