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

C++ÖеÄÊý¾ÝÀàÐÍת»»·½·¨


C++ÖеÄÊý¾ÝÀàÐÍת»»·½·¨
 
 
ÕªÒª£º±¾ÎÄ×ܽáÁËC/C++ÖеĶàÖÖÊý¾ÝÀàÐÍת»»·½·¨£¬²¢±È½ÏÁ˸÷×ÔµÄÓÅÁÓ¡£¸ø³öÁËÍƼöµÄʹÓý¨Òé¡£
´Óintµ½char*£¬»òÕß·´¹ýÀ´´Óchar*µ½int£¬ÔÚC/C++Öе½µ×ÓжàÉÙÖÖת»»·½·¨ÄØ£¿·ûºÏ±ê×¼µÄ´ó¸ÅÓÐËÄÖÖ¡£¼´CÊý¾Ýת»»º¯Êý×å¡¢sprintf/snprintf/sscanfº¯Êý×å¡¢×Ö·û´®Á÷std::stringstream¡¢std::strsteam¡£²»·ûºÏ±ê׼ȴÓÖ¹ãΪʹÓõİüÀ¨CStringºÍboost::lexical_cast¡£±¾ÎÄÖ»ÌÖÂÛ·ûºÏ±ê×¼µÄת»»·½·¨£¬ÆäÖÐstd::strstreamÓÉÓÚÒѾ­±»C++±ê׼ίԱΪָ¶¨Îª²»ÍƼöʹÓõģ¨deprecated£©£¬ËùÒÔ²»Ó迼ÂÇÁË¡£ÏÂÃæÖصãÌÖÂÛÈýÖÖ±ê׼ת»»·½·¨Ö®¼äµÄÓÅÁÓ¡£Ô´´úÂëµÄµØÖ·ÊÇ£ºhttp://download.csdn.net/source/631475
1. IntºÍchar*»òstd::stringÖ®¼äµÄת»»
CÊý¾Ýת»»º¯Êý×å
CÊý¾Ýת»»º¯Êý×å¼´°üÀ¨itoa¡¢atoiµÈÊý¾ÝÀàÐÍת»»º¯ÊýÔÚÄÚµÄÒ»´óÅúCº¯Êý£¬ÔÚCÓïÑÔʱ´úÔø¾­±»´óÁ¿Ê¹Óá£Ô´´úÂëÈçÏ£º
int i = 10;
char szBuf[10] = "";
itoa(i, szBuf, 10);
cout<<"itoa: szBuf = "<<szBuf<<endl;
i = 0;
i = atoi(szBuf);
cout<<"atoi: i = "<<i<<endl;
ʹÓû¹ÊDZȽϼòµ¥µÄ¡£Ò»¸ö×î´óµÄÎÊÌâÊÇ£ºÃ»ÓнøÐÐchar*µÄÔ½½ç¼ì²é£¬¿ÉÄÜ»áÔì³ÉÊý×éÒç³ö¡£
snprintf/sscanf
sprintfÊÇÓÃÀ´¸ñʽ»¯×Ö·û´®µÄÒ»¸öCº¯Êý£¬sscanfÔòÊÇ´Ó×Ö·û´®ÖжÁÈ¡ÖµµÄÒ»¸öCº¯Êý¡£ÓÉÓÚHerb Sutter£¨Exceptional C++ϵÁÐÖø×÷µÄ×÷Õߣ©½Ìµ¼ÎÒÃÇ“ÓÀÔ¶Ò²²»ÒªÊ¹ÓÃsprintf”£¬ËùÒÔÕâÀïÎÒÃÇֻʹÓÃsnprintf¡£ÓÉÓÚsnprintf½øÈëC±ê×¼½ÏÍí£¬ËùÒÔÔÚÄãµÄ±àÒëÆ÷ÖÐÒ²ÐíÖ»ÄÜʹÓ÷DZê×¼µÄ_snprintf£¨ÀýÈçÎÒµÄVC6ƽ̨£©¡£Ô´´úÂëÈçÏ£º
int i = 20;
char szBuf[10] = "";
memset(szBuf, 0, sizeof(szBuf));
_snprintf(szBuf, sizeof(szBuf), "%d", i);
cout<<"_snprintf: szBuf = "<<szBuf<<endl;
i = 0;
sscanf(szBuf,"%d",&i);
cout<<"sscanf: i = "<<i<<endl;
ʹÓúܼòµ¥£¬¶øÇÒ£¬ËƺõûÓÐʲôÄÚ´æ鶻òÕßÊý×éÔ½½ç¡£
std::stringstream
¶ÔÁ÷ºÜÊìϤµÄÈË¿ÉÄÜ»á¸ü¿ìÊÊÓ¦std::stringstreamµÄ½â¾ö·½°¸£º
#include <sstream>
using namespace std;
int i = 30;
string strRel;
ostringstream oss;
oss<<i;
strRel = oss.str();
cout<<"ostringstream: strRel = "<<strRel<<endl;
i = 0;
istringstream iss(strRel);
iss>>i;
co


Ïà¹ØÎĵµ£º

ÈçºÎʹÓ÷ºÐÍÄ£擬virtual? (C/C++) (template)

ÍøÉÏÒ»µÀ½ðɽµÄÃæÊÔÌ⣺
http://topic.csdn.net/u/20100524/14/0eff992a-2849-4db6-bdaa-d4a200e79b7c.html
Çë·Ö±ðÓÃC++µÄÃæÏò¶ÔÏóºÍ·ºÐÍ»úÖÆ£¬±àдʵÏÖTemplate MethodģʽµÄʾÀý´úÂ룬²¢±È½ÏÁ½ÖÖ·½Ê½¸÷×ÔµÄÓÅȱµã¡£
ÓÃÐ麯ÊýʵÏÖTemplate MethodµÄ·½Ê½¾Í²»¶à˵ÁË¡£Ó÷ºÐ͵ķ½Ê½ÊµÏÖ¶à̬ÔÚATLÀïÃæÓдóÁ¿µÄÓõ½£¡
·ºÐ͵ ......

ÈçºÎÔÚLinuxʹÓÃEclipse + CDT¿ª·¢C/C++³ÌÐò?

A. ΪʲôҪÔÚLinuxʹÓÃEclipse¿ª·¢C/C++³ÌÐò?
LinuxÊÇÒ»¸öÒÔC/C++¿ª·¢ÎªÖ÷µÄƽ̨£¬ÎÞÂÛÊÇKernel»òÊÇApplication£¬Ö÷Òª¶¼Ê¹ÓÃC/C++¿ª·¢¡£´«Í³ÔÚLinuxÏ¿ª·¢³ÌÐò£¬ÊÇÔÚÎÄ×ÖģʽÏ£¬ÀûÓÃviµÈÎÄ×ֱ༭Æ÷׫дC/C++³ÌÐò´æÅ̺ó£¬ÔÚCommand lineÏÂʹÓÃgcc±àÒ룬ÈôÒªdebug£¬ÔòʹÓÃgdb¡£
ÕâÖÖ¿ª·¢·½Ê½Éú²úÁ¦²¢²»¸ß£¬ÈôÖ»ÊÇ¿ª·¢Ñ§ ......

CºÍC++ÖеÄÖ÷ÒªÊý¾ÝÀàÐͺÍ×Ö½Ú´óС

CºÍC++ÖеÄÖ÷ÒªÊý¾ÝÀàÐͺÍ×Ö½Ú´óС(
    C/C++µÄд·¨ÊDz»¿ÆѧºÍ²»ÑϽ÷µÄ¡£ÒòΪCºÍC++ËäÈ»ÓïÒ壬µ«ÊÇÉè¼Æ˼ÏëÊǽṹ»¯ÓëÃæÏò¶ÔÏó. C±ê×¼¹æ·¶ÓëC++µÄ±ê×¼¹æ·¶Ò²ÊÇÁ½¸öÎı¾¡£½üÀ´×ÐϸÑо¿ÁËËüÃǵÄÊý¾ÝÀàÐÍ£¬²ÅÖªµÀÆäÀ´ÁúÈ¥Âö£¬ÕæÕý×öµ½ÆäʵËùÒÔÈ»¡£
1¡¢CÓïÑÔ¶¨ÒåÁË5ÖÖ»ù±¾Êý¾ÝÀàÐÍ
  char(×Ö·û), int(Õ ......

ÔÚEclipseϵÄC/C++¿ª·¢£¨Eclipse3.2 + CDT 3.1£©


ÒªÈàEclipse ¿ÉÒÔ¿ª·¢ C/C++ ³Ìʽ£¬Òª¹ÒÉÏ CDT ²Å¿ÉÒÔ¡£
 
Ê×ÏÈÒªÏÂÔØCDT
 
CDTµÄ×îа汾ÊÇ 3.1.0£¬ËüÖ§³Öeclipse3.2.0£¬ÆäÏÂÔصØÖ·£ºhttp://download3.eclipse.org/tools/cdt/releases/callisto/dist/3.1.0/£¬»òÕßÊǵ½http://www.eclipse.org/cdt/downloads.phpÏÂÔØÆäËü° ......

LinuxÏÂC++¿ª·¢¹¤¾ß½éÉÜ

LinuxÏÂC++¿ª·¢¹¤¾ß½éÉÜ
 
 
¡¡¡¡¸ÅÊö
¡¡¡¡¾ÍC£«£«¿ª·¢¹¤¾ß¶øÑÔ£¬ÓëWindowsÏÂ΢Èí£¨VC£¬ VS2005µÈ£©Ò»Í³ÌìÏÂÏà±È£¬Linux/UnixÏÂC£«£«¿ª·¢£¬¿ÉνÎ廨°ËÃÅ£¬¸÷ʽ¸÷Ñù¡£Emacs, vi, eclipse, anjuta£¬kdevelopµÈ²ã³ö²»Çî¡£
¡¡¡¡WindowsÏ£¬¿ª·¢¹¤¾ß¶àÒÔ¼¯³É¿ª·¢»·¾³IDEµÄÐÎʽչÏÖ¸ø×îÖÕÓû§¡£ÀýÈ磬VS2005¼¯³ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ