锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久亚洲sm情趣捆绑调教,亚洲国产精品18久久久久久,久久精品中文字幕无码绿巨人 http://www.shnenglu.com/liujiajia/瀛︿範銆佸伐浣溿佺敓媧伙紝榪欐槸涓変釜闂銆?/description>zh-cn Thu, 08 May 2025 16:28:01 GMT Thu, 08 May 2025 16:28:01 GMT 60 鏈綆鍗曠殑windows紼嬪簭 http://www.shnenglu.com/liujiajia/archive/2008/07/23/56963.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Wed, 23 Jul 2008 09:01:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/07/23/56963.html http://www.shnenglu.com/liujiajia/comments/56963.html http://www.shnenglu.com/liujiajia/archive/2008/07/23/56963.html#Feedback 3 http://www.shnenglu.com/liujiajia/comments/commentRss/56963.html http://www.shnenglu.com/liujiajia/services/trackbacks/56963.html 1.鎵撳紑vc++; 2.閫夋嫨鑿滃崟鏍廸ile----new錛?br>3.閫夐」鍗¢夋嫨Projects錛?br>4.妯℃澘閫夋嫨 Win32 Application; 5.杈撳叆Project name錛?br>6.Loction 閫夋嫨璺緞錛?br>7.鐐瑰嚮OK緇х畫錛?br>8.閫夋嫨榛樿鐨?#8220;An Empty project”錛?br>9.鐐瑰嚮finish瀹屾垚鍒涘緩宸ョ▼錛?br>10.鍚戝伐紼嬮噷闈㈡坊鍔犱竴涓猚++鏂囦歡錛涳紙file--new--閫夐」鍗ile--C++ source file--杈撳叆鏂囦歡鍚?-鐐瑰嚮OK錛?br>11.杈撳叆浠ヤ笅浠g爜錛?/p>
#define WIN32_LEAN_AND_MEAN #include< windows.h > #include< windowsx.h > int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE hprevinstance,LPSTR lpcmdline, int ncmdshow) { MessageBox(NULL, " Hello World! " , " first win " ,MB_OK | MB_ICONEXCLAMATION); return 0 ; }
12.淇濆瓨錛屾寜ctrl+F5緙栬瘧騫惰繍琛屻?br>13.寮瑰嚭涓涓璇濇銆?br> 浠ヤ笂灝辨槸鍙風О涓栫晫涓婃渶綆鍗曠殑Windows紼嬪簭錛?br>
]]> 鍑芥暟榪斿洖鍊肩殑鐗規畩鎯呭喌錛堣繑鍥炲紩鐢ㄣ侀潪寮曠敤銆佸紩鐢ㄥ乏鍊鹼級 http://www.shnenglu.com/liujiajia/archive/2008/07/16/56244.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Tue, 15 Jul 2008 16:41:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/07/16/56244.html http://www.shnenglu.com/liujiajia/comments/56244.html http://www.shnenglu.com/liujiajia/archive/2008/07/16/56244.html#Feedback 2 http://www.shnenglu.com/liujiajia/comments/commentRss/56244.html http://www.shnenglu.com/liujiajia/services/trackbacks/56244.html 榪斿洖闈炲紩鐢?/span> string make_plural(size_t i,const string &word,const string &ending) { return (i==1)?word:word+ending; } 浠ヤ笂鍑芥暟錛屽綋i絳変簬1鏃訛紝鍑芥暟榪斿洖word褰㈠弬鐨勫壇鏈紱褰搃涓嶇瓑浜?鏃跺嚱鏁拌繑鍥炰竴涓復鏃剁殑string瀵硅薄錛岃繖涓復鏃跺璞℃槸鐢卞瓧絎︿覆word鍜宔nding鐩稿姞鑰屾垚鐨勩傝繖涓ょ鎯呭喌涓嬶紝return閮藉湪璋冪敤璇ュ嚱鏁扮殑鍦版柟闃插鍒朵簡榪斿洖鐨剆tring瀵硅薄銆?br>榪斿洖寮曠敤 const string &shorterString(const string &s1,const string &s2) { return s1.size()<s2.size()?s1:s2; } 浠ヤ笂鍑芥暟鐨勮繑鍥炲兼槸寮曠敤綾誨瀷銆傛棤璁鴻繑鍥瀞1鎴栨槸s2,璋冪敤鍑芥暟鍜岃繑鍥炵粨鏋滄椂錛岄兘娌℃湁澶嶅埗榪欎簺string瀵硅薄銆?br>鍗冧竾涓嶈榪斿洖灞閮ㄥ璞$殑寮曠敤 const string &mainip(const string &s) { string ret=s; return ret; } 褰撳嚱鏁版墽琛屽畬姣曪紝紼嬪簭灝嗛噴鏀懼垎閰嶇粰灞閮ㄥ璞$殑瀛樺偍絀洪棿銆傛鏃訛紝瀵瑰眬閮ㄥ璞$殑寮曠敤灝變細鎸囧悜涓嶇‘瀹氱殑鍐呭瓨銆傦紙鎴戝湪dev c++閲岃繍琛岄氳繃銆傘傘傘?浣嗘槸vc6鍜寁c2008涓嶈兘緙栬瘧閫氳繃錛夈傚悓鐞嗭紝涔熶笉鑳借繑鍥炲眬閮ㄥ璞$殑鎸囬拡銆?br> 寮曠敤榪斿洖宸﹀鹼紙姣旇緝濂囧錛?/strong> char &get_val(string &str,string::size_type ix) { return str[ix]; } 浣跨敤璇彞璋冪敤: string s("123456"); cout<<s<<endl; get_val(s,0)='a'; cout<<s<<endl; 鎶婂嚱鏁板簲鐢ㄤ簬宸﹀鹼紝榪樻槸絎竴嬈¤鍒幫紙鐪熸槸瀛ら檵瀵¢椈錛夈?br> 浠ヤ笅鏄笂闈㈠嚑縐嶆儏鍐電殑瀹炰緥浠g爜錛?br>
// liujiajia // 2008-7-16 #include < iostream > using namespace std; string make_plural(size_t, const string & , const string & ); const string & shorterString( const string & , const string & ); const string & mainip( const string & ); char & get_val( string & , string ::size_type); int main( void ) { cout << make_plural( 1 , " dog " , " s " ) << endl; cout << make_plural( 2 , " dog " , " s " ) << endl; string string1 = " 1234 " ; string string2 = " abc " ; cout << shorterString(string1,string2) << endl; cout << mainip( " jiajia " ) << endl; string s( " 123456 " ); cout << s << endl; get_val(s, 0 ) = ' a ' ; cout << s << endl; getchar(); return 0 ; } // 榪斿洖闈炲紩鐢?nbsp; string make_plural(size_t i, const string & word, const string & ending) { return (i == 1 ) ? word:word + ending; } // 榪斿洖寮曠敤 const string & shorterString( const string & s1, const string & s2) { return s1.size() < s2.size() ? s1:s2; } // 紱佹榪斿洖灞閮ㄥ璞$殑寮曠敤錛堟垜鐨刣ev c++ 娌℃湁鎶ラ敊錛屾瘮杈冨彲鎬曪級 const string & mainip( const string & s) { string ret = s; return ret; } // 寮曠敤榪斿洖宸﹀鹼紙絎竴嬈″惉璇達級 char & get_val( string & str, string ::size_type ix) { return str[ix]; }
]]> 鏁扮粍鐨勫艦鍙?/title> http://www.shnenglu.com/liujiajia/archive/2008/07/15/56143.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Mon, 14 Jul 2008 16:05:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/07/15/56143.html http://www.shnenglu.com/liujiajia/comments/56143.html http://www.shnenglu.com/liujiajia/archive/2008/07/15/56143.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/56143.html http://www.shnenglu.com/liujiajia/services/trackbacks/56143.html 紺轟緥錛?br> //褰㈠紡1 void printValues(const int ia[10]) //铏界劧褰㈠弬鎸囧畾浜嗘暟緇勭殑澶у皬錛屼絾緙栬瘧鏃朵笉浼氭鏌ュ疄鍙傛暟緇勫ぇ灝忥紝鍥犱負緙栬瘧鍣ㄥ彧媯鏌ュ艦鍙傛槸鍚︽槸鎸囬拡錛屽茍涓旀寚閽堢被鍨嬪拰鏁扮粍鍏冪礌鐨勭被鍨嬫槸鍚﹀尮閰嶃?br> { for(size_t i=0;i!=10;i++) { cout<<ia[i]<<endl; } } //褰㈠紡2 void printValues2(const int ia[],int size) { for(size_t i=0;i!=size;i++) { cout<<ia[i]<<endl; } } int main(void) { int i[10]={1,2,3,4,5,6,7,8,9,0}; printValues(i); //i浣滀負printValues鐨勫疄鍙傦紝鍦ㄨ繖閲屼負鏁扮粍i鐨勯鍦板潃錛屾垨鑰呰浠栬漿鎹負鎴愪竴涓寚閽?br> printValues2(i,10); } 鏁扮粍褰㈠弬鍙互瀹氫箟涓哄紩鐢ㄦ垨闈炲紩鐢ㄧ被鍨嬨傚ぇ閮ㄥ垎鎯呭喌涓嬶紝鏁扮粍浠ユ櫘閫氱殑闈炲紩鐢ㄧ被鍨嬩紶閫?姝ゆ椂鏁扮粍浼氭倓鎮勭殑杞崲涓烘寚閽堛備竴鑸潵璇達紝闈炲紩鐢ㄧ被鍨嬬殑褰㈠弬浼氬垵濮嬪寲涓哄叾鐩稿簲瀹炲弬鐨勫壇鏈備絾鏄湪浼犻掓暟緇勬椂錛屽疄鍙傛槸鎸囧悜鏁扮粍絎竴涓厓绱犵殑鎸囬拡錛屽艦鍙傚鍒剁殑鏄繖涓寚閽堢殑鍊鹼紝鑰屼笉鏄暟緇勫厓绱犳湰韜傚嚱鏁版搷浣滅殑涔熸槸鎸囬拡鐨勫壇鏈紝鍥犳涓嶄細淇敼瀹炲弬鎸囬拡鐨勫箋傜劧鑰岋紝鍑芥暟鍙氳繃璇ユ寚閽堜慨鏀瑰畠鎵鎸囧悜鐨勬暟緇勫厓绱犵殑鍊箋?br> 浠ヤ笂浠g爜鍙互浣跨敤鎸囬拡琛ㄧず錛屾晥鏋滅瓑鍚岋細 void printValues3(const int *ia,int size) { for(size_t i=0;i!=size;i++,ia++) { cout<<*ia<<endl; } } 紺轟緥2錛堥氳繃寮曠敤浼犻掓暟緇勶級錛?br> void printValues4(int (&arr)[10]) //榪欑鎯呭喌涓嬶紝鏁扮粍澶у皬鎴愪負褰㈠弬鍜屽疄鍙傜殑涓閮ㄥ垎銆傜紪璇戝櫒浼氭鏌ユ暟緇勫ぇ灝忔槸鍚﹀尮閰嶃?nbsp;int (&arr)[10] 涓殑灝忔嫭鍙鋒槸蹇呴』鐨勩?br> { for(size_t i=0;i!=10;i++) { cout<<arr[i]<<endl; } } int main(void) { printValues4(i); } 鍜屽叾浠栫被鍨嬩竴鏍鳳紝鏁扮粍褰㈠弬鍙0鏄庝負鏁扮粍鐨勫紩鐢ㄣ傚鏋滃艦鍙傛槸鏁扮粍鐨勫紩鐢紝緙栬瘧鍣ㄤ笉浼氬皢鏁扮粍瀹炲弬杞寲涓烘寚閽堬紝鑰屾槸浼犻掓暟緇勭殑寮曠敤鏈韓銆?
]]> 浼犻掓寚鍚戞寚閽堢殑寮曠敤 http://www.shnenglu.com/liujiajia/archive/2008/07/14/56135.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Mon, 14 Jul 2008 14:19:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/07/14/56135.html http://www.shnenglu.com/liujiajia/comments/56135.html http://www.shnenglu.com/liujiajia/archive/2008/07/14/56135.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/56135.html http://www.shnenglu.com/liujiajia/services/trackbacks/56135.html
// liujiajia // 2008-7-14 #include < iostream > using namespace std; void ptrswap( int *& , int *& ); int main( void ) { int i = 10 ; int j = 20 ; int * pi =& i; int * pj =& j; cout << " 璋冪敤ptr()涔嬪墠:pi= " << pi << " ,*pi= " <<* pi << " ;pj= " << pj << " ,*pj= " <<* pj << endl; ptrswap(pi,pj); cout << " 璋冪敤ptr()涔嬪悗:pi= " << pi << " ,*pi= " <<* pi << " ;pj= " << pj << " ,*pj= " <<* pj << endl; getchar(); return 0 ; } void ptrswap( int *& v1, int *& v2) { int * temp = v1; v1 = v2; v2 = temp; }
鍦ㄨ皟鐢╬trswap涔嬪墠錛宲i鎸囧悜i,pj鎸囧悜j銆傚湪璋冪敤ptrswap涔嬪悗錛宲i鎸囧悜j,鑰宲j鎸囧悜浜唅銆?
]]> 浣跨敤寮曠敤褰㈠弬鐨勪紭鐐瑰拰娉ㄦ剰浜嬮」 http://www.shnenglu.com/liujiajia/archive/2008/07/14/56131.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Mon, 14 Jul 2008 13:48:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/07/14/56131.html http://www.shnenglu.com/liujiajia/comments/56131.html http://www.shnenglu.com/liujiajia/archive/2008/07/14/56131.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/56131.html http://www.shnenglu.com/liujiajia/services/trackbacks/56131.html 浣跨敤寮曠敤褰㈠弬鐨勪紭鐐癸細 鍦ㄥ悜鍑芥暟浼犻掑ぇ瀵硅薄鏃訛紝闇瑕佷嬌鐢ㄥ紩鐢ㄥ艦鍙傘傝櫧鐒惰祴鍊煎疄鍙傚浜庡唴緗暟鎹被鍨嬬殑瀵硅薄鎴栬呰妯¤緝灝忕殑綾葷被鍨嬫潵璇存病鏈変粈涔堥棶棰橈紝浣嗘槸瀵逛簬澶ч儴鍒嗙殑綾葷被鍨嬫垨鑰呭ぇ鍨嬫暟緇勶紝瀹冪殑鏁堢巼灝辨瘮杈冧綆浜嗐傚彟澶栵紝鏌愪簺綾葷被鍨嬫槸鏃犳硶澶嶅埗鐨勩備嬌鐢ㄥ紩鐢ㄥ艦鍙傦紝鍑芥暟鍙互鐩存帴璁塊棶瀹炲弬瀵硅薄錛岃屾棤欏誨鍒跺畠銆?br> 紺轟緥錛?br> bool isShorter(const string &str1,const string &str2) { return str1.size()<str2.size(); } 鐢變簬string瀵硅薄鍙兘闈炲父鐨勯暱錛屾垜浠笇鏈涢伩鍏嶅鍒舵搷浣溿?br> 濡傛灉浣跨敤寮曠敤褰㈠弬鐨勫敮涓鐩殑鏄伩鍏嶅鍒跺艦鍙傦紝鍒欏簲灝嗗艦鍙傚畾涔変負const寮曠敤銆?br> 浣跨敤寮曠敤褰㈠弬搴旇娉ㄦ剰鐨勶細 int incr(int &val) { return ++val; } void main(void) { short v1=1; const int v2=10; int v3=20; incr(v1); //閿欒錛寁1涓嶆槸int incr(v2); //閿欒錛寁2鏄痗onst incr(v3); //姝g‘ incr(10); //閿欒 } 鎵浠ワ紝璋冪敤闈瀋onst綾誨瀷鐨勫紩鐢ㄥ艦鍙傦紝瀹炲弬蹇呴』涓嶆槸const綾誨瀷鐨勶紝鑰屼笖瀹炲弬鐨勭被鍨嬪拰褰㈠弬鐨勭被鍨嬪簲褰撲竴鑷淬?/p>
]]> 浣跨敤寮曠敤褰㈠弬榪斿洖棰濆鐨勪俊鎭?/title> http://www.shnenglu.com/liujiajia/archive/2008/07/14/56085.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Mon, 14 Jul 2008 04:12:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/07/14/56085.html http://www.shnenglu.com/liujiajia/comments/56085.html http://www.shnenglu.com/liujiajia/archive/2008/07/14/56085.html#Feedback 4 http://www.shnenglu.com/liujiajia/comments/commentRss/56085.html http://www.shnenglu.com/liujiajia/services/trackbacks/56085.html 鍥犱負寮曠敤褰㈠弬鍦ㄥ嚱鏁拌皟鐢ㄥ悗鏄彲浠ヤ慨鏀瑰疄鍙傚肩殑錛屾墍浠ュ氨鐩稿綋涓庡嚱鏁扮殑榪斿洖鍊箋?br> 涓嬮潰鐨勪唬鐮佹紨紺轟簡涓涓甫鏈変竴涓繑鍥炲鹼紝騫墮氳繃寮曠敤褰㈠弬鍚戜富璋冨嚱鏁拌繑鍥炰俊鎭殑鍑芥暟銆傝繖涓嚱鏁扮殑鍔熻兘鏄壘鍑哄湪瀹瑰櫒涓煇涓涓暟鍊煎嚭鐜扮殑嬈℃暟錛屽茍榪斿洖璇ユ暟鍊肩涓嬈″嚭鐜扮殑榪唬鍣ㄣ?br>
// liujiajia // 2008-7-14 #include < iostream > #include< vector > using namespace std; vector < int > ::const_iterator find_val(vector < int > ::const_iterator,vector < int > ::const_iterator, int ,vector < int > ::size_type & ); int main( void ) { vector < int > some; int val; // 浣跨敤push_back()杈撳叆瀹瑰櫒涓殑鍊?nbsp; while (cin >> val) { some.push_back(val); } // 瀛樺偍鍊煎嚭鐜扮殑嬈℃暟 vector < int > ::size_type ccurs; // 璋冪敤鍑芥暟 vector < int > ::const_iterator it = find_val(some.begin(),some.end(), 8 ,ccurs); cout << ccurs << endl; getchar(); } vector < int > ::const_iterator find_val( vector < int > ::const_iterator beg, vector < int > ::const_iterator end, int value, vector < int > ::size_type & occurs) { vector < int > ::const_iterator res_iter = end; occurs = 0 ; for (;beg != end; ++ beg) { if ( * beg == value) { // 榪欎釜if璇彞鐨勪綔鐢ㄦ槸璁﹔es_iter絳変簬鍊肩涓嬈″嚭鐜扮殑浣嶇疆 if (res_iter == end) { res_iter = beg; } occurs ++ ; } } return res_iter; }
]]> 鍑芥暟鐨勫艦鍙傦紙闈炲紩鐢ㄥ艦鍙傘佹寚閽堝艦鍙傘佸紩鐢ㄥ艦鍙傦級 http://www.shnenglu.com/liujiajia/archive/2008/07/14/56054.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Sun, 13 Jul 2008 16:30:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/07/14/56054.html http://www.shnenglu.com/liujiajia/comments/56054.html http://www.shnenglu.com/liujiajia/archive/2008/07/14/56054.html#Feedback 2 http://www.shnenglu.com/liujiajia/comments/commentRss/56054.html http://www.shnenglu.com/liujiajia/services/trackbacks/56054.html void add1(int v1) { v1+=1; } 榪欐槸鏈鏅氱殑褰㈠弬鏂瑰紡錛屽綋鍑芥暟琚皟鐢ㄦ椂錛屽疄鍙傜殑鍓湰鍒濆鍖栧艦鍙傦紝鍑芥暟騫舵病鏈夎闂皟鐢ㄦ墍浼犻掔殑瀹炲弬錛屽洜姝1+=1涓嶄細淇敼瀹炲弬鐨勫箋傚v1鐨勬搷浣滃彧鏄慨鏀逛簡瀹炲弬鐨勪竴涓壇鏈?br> 浜屻佹寚閽堝艦鍙?br> void add2(int *p) { *p+=1; p+=1; } 浣跨敤鎸囬拡鍋氫負鍑芥暟鐨勫艦鍙傦紝鍚屾牱鎸囬拡鐨勫鹼紙鎸囬拡鐨勫湴鍧錛変笉浼氬洜涓簆+=1鑰屽彈鍒板獎鍝嶏紝浣嗘槸鎸囬拡鎸囧悜鐨勫湴鍧鐨勫鹼紙*p錛夊皢浼氭敼鍙樸傛墍浠ヨ鎯充慨鏀瑰疄鍙傜殑鍊鹼紝鍙互浣跨敤榪欑鏂規硶銆備絾鏄繕鏈変竴縐嶆洿瀹夊叏鏇磋嚜鐒剁殑鏂規硶-寮曠敤褰㈠弬 涓夈佸紩鐢ㄥ艦鍙?br> void swap(int &a,int &b) { int temp=a; a=b; b=temp; } 寮曠敤褰㈠弬鐩存帴鍏寵仈鍒板叾鎵緇戝畾鐨勫璞★紝鑰岄潪榪欎簺瀵硅薄鐨勫壇鏈?鎵浠ヨ繖縐嶆柟娉曞彲浠ヤ慨鏀瑰疄鍙傜殑鍊鹼紝鑰屼笖鏇村姞鐩磋銆?br> 涓夌鏂規硶瀹炰緥浠g爜錛?br>
// liujiajia // 2008-7-14 #include < iostream > using namespace std; void add1( int ); void add2( int * ); void swap( int & , int & ); int main( void ) { int n = 10 ; cout << " 璋冪敤add1()涔嬪墠n= " << n << endl; add1(n); cout << " 璋冪敤add1()涔嬪悗n= " << n << endl; int * p =& n; cout << " 璋冪敤add2()涔嬪墠n= " << n << " ,p= " << p << endl; add2(p); cout << " 璋冪敤add2()涔嬪悗n= " << n << " ,p= " << p << endl; int a = 1 ,b = 2 ; cout << " 璋冪敤swap()涔嬪墠a= " << a << " ,b= " << b << endl; swap(a,b); cout << " 璋冪敤swap()涔嬪悗a= " << a << " ,b= " << b << endl; getchar(); } // 闈炲紩鐢ㄥ艦鍙?nbsp; void add1( int v1) { v1 += 1 ; } // 鎸囬拡褰㈠弬 void add2( int * p) { * p += 1 ; p += 1 ; } // 寮曠敤褰㈠弬 void swap( int & a, int & b) { int temp = a; a = b; b = temp; }
]]> 鍒涘緩鍜屼嬌鐢ㄥ姩鎬佹暟緇?/title> http://www.shnenglu.com/liujiajia/archive/2008/07/12/55984.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Sat, 12 Jul 2008 15:26:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/07/12/55984.html http://www.shnenglu.com/liujiajia/comments/55984.html http://www.shnenglu.com/liujiajia/archive/2008/07/12/55984.html#Feedback 2 http://www.shnenglu.com/liujiajia/comments/commentRss/55984.html http://www.shnenglu.com/liujiajia/services/trackbacks/55984.html 瀹氫箟錛?/strong> int *p=new int[20]; p灝辨槸涓涓姩鎬佹暟緇勶紝榪欐椂鎴戜滑鍙戠幇錛屽叾瀹炴墍璋撶殑鍔ㄦ佹暟緇勫氨鏄竴涓寚閽堬紝浣跨敤new涓簆鍒嗛厤闀垮害銆傛垜浠彲浠ラ氳繃榪欑鏂瑰紡鍒濆鍖栵細 int *p=new int[20](); 鍚屾牱涓婇潰鐨勮鍙ョ瓑鍚屼簬錛?br> int n=20; int *p=new int[n]; 鍥犱負n鏄竴涓彉閲忥紝鎵浠ユ暟緇勭殑闀垮害鏄姩鎬佺殑銆?br>鎿嶄綔瀹炰緥錛?/strong> int n=20; int *p=new int[n]; p鍙互浣跨敤鏁扮粍涓嬫爣涓哄叾璧嬪鹼細 for(int i=0;i<n;i++) { p[i]=i+3; } 涓婇潰榪欑鏂瑰紡娌℃湁闂錛屼絾鎴戞兂鏃㈢劧p鏄竴涓寚閽堬紝閭d箞浣跨敤鎸囬拡鎿嶄綔涓鏍蜂篃鍙互鍚э紵 for(int i=0;i<n;i++,p++) { *p=i; } 榪欐牱灝卞彲浠ヤ簡錛屽皢浠栦滑杈撳嚭錛氾紙榪欐椂鎸囬拡p鍙堟寚鍚戜簡鏈鍚庯級 p--; for(int *p2=p-10;p2!=p;p--) { cout<<*p<<endl; }鍔ㄦ佺┖闂撮噴鏀撅細 鏈鍚庨噸瑕佺殑鏄埆蹇樹簡灝嗗姩鎬佸垱閫犵殑絀洪棿閲婃斁鎺夛紝璇彞鏄細delete [] p; ‘[ ]’琛ㄦ槑璇ユ寚閽堟槸鎸囧悜鐨勮嚜鐢卞瓨鍌ㄥ尯鐨勬暟緇勶紝鑰岄潪鍗曚釜瀵硅薄銆傚鏋滈仐婕忎簡絀烘柟鎷彿錛岀紪璇戝櫒灝嗘棤娉曞彂鐜拌繖涓敊璇紝灝嗗鑷寸▼搴忓湪榪愯鏃跺嚭閿欍?br> 瀹屾垚浜嗭紒浠ヤ笅鏄畬鏁翠唬鐮侊細
#include < iostream > using namespace std; int main( void ) { int n = 20 ; int * p = new int [n]; for ( int i = 0 ;i < n;i ++ ,p ++ ) { cout << p << endl; * p = i; } p -- ; for ( int * p2 = p - n;p2 != p;p -- ) { cout <<* p << endl; } delete [] p; getchar(); }
]]> const鍜屾寚閽堬紙鎸囧悜const瀵硅薄鐨勬寚閽堛乧onst鎸囬拡錛?/title> http://www.shnenglu.com/liujiajia/archive/2008/06/21/54166.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Fri, 20 Jun 2008 16:13:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/06/21/54166.html http://www.shnenglu.com/liujiajia/comments/54166.html http://www.shnenglu.com/liujiajia/archive/2008/06/21/54166.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/54166.html http://www.shnenglu.com/liujiajia/services/trackbacks/54166.html 1.鎸囧悜const瀵硅薄鐨勬寚閽?/strong> const int *p; 榪欎釜p鏄竴涓寚鍚慽nt綾誨瀷const瀵硅薄鐨勬寚閽堬紝const闄愬畾浜嗘寚閽坧鎵鎸囧悜鐨勭被鍨嬶紝鑰屽茍闈瀙鏈韓銆備篃灝辨槸璇磒鏈韓騫朵笉鏄痗onst銆傚湪瀹氫箟鏃朵笉闇瑕佸瀹冭繘琛屽垵濮嬪寲錛岃繕鍙互緇檖閲嶆柊璧嬪鹼紝浣垮叾鎸囧悜鍙︿竴涓猚onst瀵硅薄銆備絾涓嶈兘閫氳繃p淇敼鎵鎸囧悜瀵硅薄鐨勫箋?br>紺轟緥1錛歩nt a=0; p=&a; 鍙互銆?br>紺轟緥2錛?p=20; 涓嶅彲浠ャ?br>緇撹錛氳繖縐嶆寚鍚慶onst瀵硅薄鐨勬寚閽堝彧鏄檺鍒朵笉鑳戒慨鏀筽鎸囧悜瀵硅薄鐨勬暟鍊鹼紝鑰屼笉鏄檺鍒秔鎸囧悜浠涔堝璞°?br> 鎶婁竴涓猚onst瀵硅薄鐨勫湴鍧璧嬬粰涓涓笉鏄寚鍚慶onst瀵硅薄鐨勬寚閽堜篃鏄笉琛岀殑銆?br>紺轟緥3錛歝onst int b=10; int *p2=&b; //error const int *p3=&b; //ok 緇撹錛氬洜涓哄彉閲廱鏈塩onst淇グ錛屼笉鑳借淇敼銆備絾鎸囬拡p2鏄竴涓櫘閫氱殑鎸囬拡錛屽彲浠ヤ慨鏀規寚鍚戝璞$殑鍊鹼紝涓ょ澹版槑鐭涚浘錛屾墍浠ヤ笉鍚堟硶銆傝屾寚鍚慶onst瀵硅薄鐨勬寚閽堜笉鍏佽淇敼鎸囬拡鎸囧悜瀵硅薄鐨勬暟鍊鹼紝鎵浠ヨ繖縐嶆柟寮忓悎娉曘?br>2.const鎸囬拡 int c=20; int *const p4=&c; 鎸囬拡p4縐頒負const鎸囬拡銆傚畠鍜屾寚鍚慶onst瀵硅薄鐨勬寚閽堟伆濂界浉鍙嶏紝瀹冧笉鑳藉淇敼鎵鎸囧悜瀵硅薄錛屼絾鍗磋兘澶熶慨鏀規寚鍚戝璞$殑鏁板箋傚彟澶栵紝榪欑鎸囬拡鍦ㄥ0鏄庢椂蹇呴』鍒濆鍖栥?br>3.鎸囧悜const瀵硅薄鐨刢onst鎸囬拡 const int d=30; const int *const dp=&d; 鎸囬拡dp鏃笉鑳戒慨鏀規寚鍚戠殑瀵硅薄錛屼篃涓嶈兘淇敼鍙兂瀵硅薄鐨勫箋?
]]> 鏍囧噯搴?bitset 綾誨瀷 http://www.shnenglu.com/liujiajia/archive/2008/06/06/52400.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Fri, 06 Jun 2008 15:04:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/06/06/52400.html http://www.shnenglu.com/liujiajia/comments/52400.html http://www.shnenglu.com/liujiajia/archive/2008/06/06/52400.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/52400.html http://www.shnenglu.com/liujiajia/services/trackbacks/52400.html bitset瀵硅薄鐨勫畾涔夊拰鍒濆鍖?br> bitset<n> b; b鏈塶浣嶏紝姣忎綅閮芥槸0錛?br>bitset<n> b(u); b鏄痷nsigned long鍨媢鐨勫壇鏈紱 bitset<n> b(s); b鏄痵tring瀵硅薄s涓惈鏈夌殑浣嶄覆鐨勫壇鏈紱 bitset<n> b(s,pos,n); b鏄痵涓粠浣嶇疆pos寮濮嬬殑n涓綅鐨勫壇鏈紱 紺轟緥錛?br> bitset<16> bitvec1(0xffff); //bitvec1鐨?-15浣嶉兘鏄? bitset<32> bitvec2(0xffff); //bitvec2鐨?-15涓烘槸1錛?6-31鏄? bitset<128> bitvec3(0xffff); //bitvec3鐨?-15浣嶆槸1錛?6-127閮芥槸0 string str("1100"); bitset<32> bitvec4(str); //bitvec4鐨勭2銆佺3浣嶆槸1錛屽叾浣欓兘鏄?銆傚洜涓簊tring瀵硅薄鍜宐itset瀵硅薄涔嬮棿鏄弽鍚戣漿鍖栫殑錛歴tring瀵硅薄鐨勬渶鍙寵竟瀛楃錛堝嵆涓嬫爣鏈澶х殑閭d釜瀛楃錛夌敤鏉ュ垵濮嬪寲bitset瀵硅薄鐨勪綆浠蜂綅錛堝嵆灝忔爣涓?鐨勪綅錛?br> bitset瀵硅薄鐨勬搷浣滐細 b.any() b涓槸鍚﹀瓨鍦ㄧ疆涓?鐨勪簩榪涘埗浣嶏紵 b.none() b涓笉瀛樺湪緗負1鐨勪簩榪涘埗浣嶅悧錛?br>b.count() b涓間負1鐨勪簩榪涘埗浣嶇殑涓暟 b.size() b涓簩榪涘埗浣嶇殑涓暟 b[pos] 璁塊棶b涓湪pos澶勭殑浜岃繘鍒朵綅 b.test(pos) b涓湪pos澶勭殑浜岃繘鍒朵綅鏄惁涓?錛?br>b.set() 鎶奲涓墍鏈夌殑浜岃繘鍒朵綅閮界疆涓? b.set(pos) 鎶奲涓湪pos澶勭殑浜岃繘鍒朵綅緗負1 b.reset() 鎶奲涓墍鏈夌殑浜岃繘鍒朵綅閮界疆涓? b.reset(pos) 鎶奲涓湪pos澶勭殑浜岃繘鍒朵綅緗負0 b.flip() 鎶奲涓墍鏈変簩榪涘埗浣嶉愪綅鍙栧弽 b.flip(pos) 鎶奲涓湪pos澶勭殑浜岃繘鍒朵綅鍙栧弽 b.to_ulong() 鐢╞涓悓鏍風殑浜岃繘鍒朵綅榪斿洖涓涓猽nsigned long鍊?br>os<<b 鍚涓殑浣嶉泦杈撳嚭鍒皁s嫻?br>
]]> 榪唬鍣?iterator http://www.shnenglu.com/liujiajia/archive/2008/06/06/52399.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Fri, 06 Jun 2008 14:32:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/06/06/52399.html http://www.shnenglu.com/liujiajia/comments/52399.html http://www.shnenglu.com/liujiajia/archive/2008/06/06/52399.html#Feedback 3 http://www.shnenglu.com/liujiajia/comments/commentRss/52399.html http://www.shnenglu.com/liujiajia/services/trackbacks/52399.html 榪唬鍣?/strong>(iterator)鏄竴涓鏌ュ鍣ㄥ唴鍏冪礌騫墮亶鍘嗗厓绱犵殑鏁版嵁綾誨瀷銆?br> 姣忕瀹瑰櫒綾誨瀷閮藉畾涔変簡鑷繁鐨勮凱浠e櫒綾誨瀷錛屽vector: vector<int>::iterator iter;榪欐潯璇彞瀹氫箟浜嗕竴涓悕涓篿ter鐨勫彉閲忥紝瀹冪殑鏁版嵁綾誨瀷鏄敱vector<int>瀹氫箟鐨刬terator綾誨瀷銆?br>浣跨敤榪唬鍣ㄨ鍙杤ector涓殑姣忎竴涓厓绱狅細 vector<int> ivec(10,1); for(vector<int>::iterator iter=ivec.begin();iter!=ivec.end();++iter) { *iter=2; //浣跨敤 * 璁塊棶榪唬鍣ㄦ墍鎸囧悜鐨勫厓绱?br> }const_iterator: 鍙兘璇誨彇瀹瑰櫒涓殑鍏冪礌錛岃屼笉鑳戒慨鏀廣?br> for(vector<int>::const_iterator citer=ivec.begin();citer!=ivec.end();citer++) { cout<<*citer; //*citer=3; error }vector<int>::const_iterator 鍜?const vector<int>::iterator鐨勫尯鍒?br> const vector<int>::iterator newiter=ivec.begin(); *newiter=11; //鍙互淇敼鎸囧悜瀹瑰櫒鐨勫厓绱?br> //newiter++; //榪唬鍣ㄦ湰韜笉鑳借淇敼 iterator鐨勭畻鏈搷浣滐細 iterator闄や簡榪涜++,--鎿嶄綔錛屽彲浠ュ皢iter+n,iter-n璧嬬粰涓涓柊鐨刬teraor瀵硅薄銆傝繕鍙互浣跨敤涓涓猧terator鍑忓幓鍙﹀涓涓猧terator. const vector<int>::iterator newiter=ivec.begin(); vector<int>::iterator newiter2=ivec.end(); cout<<"\n"<<newiter2-newiter ;
]]> 璁よ瘑鏍囧噯搴搗ector綾誨瀷 http://www.shnenglu.com/liujiajia/archive/2008/06/02/51928.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Mon, 02 Jun 2008 15:48:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/06/02/51928.html http://www.shnenglu.com/liujiajia/comments/51928.html http://www.shnenglu.com/liujiajia/archive/2008/06/02/51928.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/51928.html http://www.shnenglu.com/liujiajia/services/trackbacks/51928.html vector 鏄竴涓被妯℃澘(class template)銆?br>vector鐨勫畾涔夊拰鍒濆鍖栵細 vector<string> text; //淇濆瓨綾誨瀷涓簊tring鐨勫璞★紝榛樿鏋勯犲嚱鏁皌ext涓虹┖ vector<string> text2(10); //淇濆瓨綾誨瀷涓簊tring鐨勫璞★紝鍖呭惈10涓┖瀛楃涓?br> vector<int> ive(10,9); //淇濆瓨int鐨勫璞★紝淇濆瓨10涓間負9鐨勬暣褰㈠彉閲?br> vector<int> ive2(ive); //浣跨敤ive鍒濆鍖杋ve2鍚憊ector娣誨姞鍏冪礌錛?br> while(cin>>word) { text.push_back (word); //浣跨敤push_back鍙互鍚憊ector鐨勫悗闈㈡彃鍏ユ柊鐨勫厓绱犮?br> } 娉ㄦ剰錛?vector瀵硅薄錛堜互鍙婂叾浠栨爣鍑嗗簱瀹瑰櫒瀵硅薄錛夌殑閲嶈灞炴у氨鍦ㄤ簬鍙互鍦ㄨ繍琛屾椂楂樻晥鐨勬坊鍔犲厓绱狅紝鍥犱負vector澧為暱鏁堢巼楂橈紝鍦ㄥ厓绱犲煎凡鐭ョ殑鎯呭喌涓嬶紝鏈濂芥槸鍔ㄦ佺殑娣誨姞鍏冪礌銆?br> *铏界劧鍙互瀵圭粰瀹氬厓绱犱釜鏁扮殑vector瀵硅薄棰勫厛鍒嗛厤鍐呭瓨錛屼絾鏇存湁鏁堢殑鏂規硶鏄垵濮嬪寲涓涓┖vector瀵硅薄錛岀劧鍚庡啀鍔ㄦ佺殑澧炲姞鍏冪礌銆?br>vector鐨勪笅鏍囨搷浣滐細 for(vector<string>::size_type ix=0;ix!=text.size ();++ix) { cout<<text[ix] <<endl; } *浣跨敤vector<string>::size_type綾誨瀷鍙互鎺ユ敹vector<string>綾誨瀷鐨勫ぇ灝忋?br>*涓嶅湪for寰幆涔嬪墠鍙栧緱vector鐨勫ぇ灝忥紝鑰屽湪for寰幆涓綆梩ext.size()錛屾槸鍥犱負vector鏄彲浠ュ闀跨殑錛屾墍浠ュ畠鐨勫厓绱犳暟鐩槸涓嶇‘瀹氱殑銆?br>*鍜宻tring瀵硅薄涓鏍鳳紝vector鍙互閫氳繃涓嬫爣鐩存帴璁塊棶鍏冪礌銆?br>闄勮〃錛歷ector鎿嶄綔
v.empty()
濡傛灉v涓虹┖錛屽垯榪斿洖true
v.size()
榪斿洖v涓厓绱犵殑涓暟
v.push_back(t)
闇鎸変笉榪噕鐨勬湯灝懼鍔犱竴涓間負t鐨勫厓绱?/td>
v[n]
榪斿洖v涓綅緗負n鐨勫厓绱?/td>
v1=v2
鍚1鐨勫間笌鏇挎崲涓簐2涓厓绱犵殑鍓湰
v1==v2
濡傛灉v1涓巚2鐩哥瓑錛屽垯榪斿洖true
!=,<,<=,>,>=
淇濇寔榪欎簺鎿嶄綔絎︽儻鏈夌殑鍚箟
]]> c++瀛楃澶勭悊 cctype http://www.shnenglu.com/liujiajia/archive/2008/06/01/51853.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Sun, 01 Jun 2008 15:45:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/06/01/51853.html http://www.shnenglu.com/liujiajia/comments/51853.html http://www.shnenglu.com/liujiajia/archive/2008/06/01/51853.html#Feedback 2 http://www.shnenglu.com/liujiajia/comments/commentRss/51853.html http://www.shnenglu.com/liujiajia/services/trackbacks/51853.html
isalnum(c)
濡傛灉c鏄瓧姣嶆垨鏁板瓧錛屽垯涓簍rue
isalpah(c)
濡傛灉c鏄瓧姣嶏紝鍒欎負true
iscntrl(c)
濡傛灉c鏄帶鍒跺瓧絎︼紝鍒欎負true
isdigit(c)
濡傛灉c鏄暟瀛楋紝鍒欎負true
isgraph(c)
濡傛灉c涓嶆槸絀烘牸錛屽垯涓簍rue
islower(c)
濡傛灉c鏄皬鍐欏瓧姣嶏紝鍒欎負true
isprint(c)
濡傛灉c鏄彲鎵撳嵃鐨勫瓧絎︼紝鍒欎負true
ispunct(c)
濡傛灉c鏄爣鐐圭鍙鳳紝鍒欎負true
isspace(c)
濡傛灉c鏄┖鐧藉瓧絎︼紝鍒欎負true
isupper(c)
濡傛灉c鏄ぇ浜涘瓧姣嶏紝鍒欎負true
isxdigit(c)
濡傛灉c鏄崄鍏繘鍒舵暟錛屽垯涓簍rue
tolower(c)
濡傛灉c鏄ぇ鍐欏瓧姣嶏紝鍒欒繑鍥炲皬鍐欏瓧姣嶅艦寮忥紝鍚﹀垯榪斿洖c銆?/td>
toupper(c)
濡傛灉c鏄皬鍐欏瓧姣嶏紝鍒欒繑鍥炲ぇ浜涘瓧姣嶅艦寮忥紝鍚﹀垯榪斿洖c銆?/td>
]]> string瀵硅薄鐨勬搷浣?size() empty() 鍏崇郴榪愮畻 璧嬪?涓嬫爣璁塊棶 http://www.shnenglu.com/liujiajia/archive/2008/06/01/51849.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Sun, 01 Jun 2008 15:22:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/06/01/51849.html http://www.shnenglu.com/liujiajia/comments/51849.html http://www.shnenglu.com/liujiajia/archive/2008/06/01/51849.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/51849.html http://www.shnenglu.com/liujiajia/services/trackbacks/51849.html string瀵硅薄鐨勬搷浣滐細 size(): 鐢ㄦ潵鑾峰彇瀛楃涓茬殑闀垮害銆?br>杈撳嚭瀛楃涓瞫鐨勯暱搴︼細 string s("hello world!\n"); cout<<"the size of '"<<s<<"' is"<<s.size ()<<endl; 鍒ゆ柇瀛楃涓叉槸鍚︿負絀虹殑涓ょ鏂瑰紡錛?br> if(s.size ()==0) { cout<<"s.size==0"<<endl; } if(s.empty ()) { cout<<"s.empty()"<<endl; }鑾峰緱瀛楃涓查暱搴︼細 int num=s.size(); 浣跨敤鏁村艦鎺ユ敹瀛楃涓查暱搴﹀彲鑳戒細鏈夐棶棰橈紝鍥犱負int鍙橀噺鐨勮〃紺鴻寖鍥村お灝忥紝鏈夋椂涓嶈兘瀛樺偍string瀵硅薄鐨勯暱搴︺備嬌鐢╯tring::size_type綾誨瀷鍙互婊¤凍瑕佹眰錛岃繖縐嶇被鍨嬫槸unsigned鐨勶紝榪欐瘮signed綾誨瀷瑕佸ぇ涓鍊嶃備簨瀹炰笂size()鍑芥暟榪斿洖鐨勪篃鏄?size_type 綾誨瀷銆?br>鍏崇郴榪愮畻錛?br> 鍙互浣跨敤錛歴1==s2錛泂1>s2錛泂1<s2錛屾潵姣旇緝涓や釜瀛楃涓層?br>璧嬪艱繍綆楋細 string snew="empty"; snew=s1; 涓婇潰浠g爜棣栧厛鍒濆鍖栦竴涓猻new瀛楃涓詫紝絎簩鍙ュ皢snew鍗犵敤鐨勫唴瀛橀噴鏀炬帀錛岀劧鍚庣粰snew瓚沖瀛樻斁s1鍓湰鐨勫唴瀛樼┖闂達紝鏈鍚庢妸s1涓墍鏈夌殑瀛楃澶嶅埗鍒版柊鍒嗛厤鐨勫唴瀛樼┖闂淬?br>瀛楃涓茶繛鎺ワ細 cout<<s1+"."<<endl; OK cout<<"1"+s1<<endl; OK cout<<s1+s2<<endl; OK cout<<s1+s2+"."<<endl; OK //cout<<"hello"+"jiajia"<<endl; ERROR 褰撹繘琛宻tring瀵硅薄鍜屽瓧絎︿覆瀛楅潰鍊兼販鍚堣繛鎺ユ搷浣滄椂錛?鎿嶄綔絎︾殑宸﹀彸鎿嶄綔鏁板繀欏昏嚦灝戞湁涓涓槸string綾誨瀷鐨勩?br>閫氳繃涓嬫爣璁塊棶string瀵硅薄錛?/strong> string瀵硅薄涓嬫爣浠?寮濮嬨?br> for(string::size_type ix=0;ix<s1.size();ix++) { s1[ix]+=ix; }
]]> 瀛楃涓茬殑璇誨彇 cin 鍜?getline() http://www.shnenglu.com/liujiajia/archive/2008/06/01/51716.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Sat, 31 May 2008 16:02:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/06/01/51716.html http://www.shnenglu.com/liujiajia/comments/51716.html http://www.shnenglu.com/liujiajia/archive/2008/06/01/51716.html#Feedback 1 http://www.shnenglu.com/liujiajia/comments/commentRss/51716.html http://www.shnenglu.com/liujiajia/services/trackbacks/51716.html cin string s; cout<<"Enter some words..."; cin >>s; cout<<"You write:"<<s<<endl; *璇誨彇騫跺拷鐣ュ紑澶存墍鏈夌殑絀虹櫧瀛楃錛堢┖鏍箋佹崲琛岀銆佸埗琛ㄧ錛夈?br>*璇誨彇瀛楃鐩磋嚦閬囧埌絀虹櫧瀛楃錛岃鍙栫粓姝€?br>getline() string line; cout<<"Enter a line..."; getline(cin,line); cout<<"You write:"<<line<<endl; *榪欎釜鍑芥暟鎺ユ敹涓や釜鍙傛暟錛岀涓涓槸杈撳叆嫻佸璞★紝絎簩涓槸string瀵硅薄銆?br>*getline涓嶅拷鐣ヨ寮澶寸殑鎹㈣絎︼紝鍙getline()閬囧埌鎹㈣絎︼紝鍝曟槸絎竴涓瓧絎︼紝getline涔熷皢鍋滄璇誨彇瀛楃騫惰繑鍥炪?br>*鑳藉璇誨彇闄ゆ崲琛屼箣澶栫殑絀虹櫧瀛楃銆?br>
]]> c++鍒濆鍖栧瓧絎︿覆鐨勬柟寮?/title> http://www.shnenglu.com/liujiajia/archive/2008/05/31/51714.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Sat, 31 May 2008 15:48:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/31/51714.html http://www.shnenglu.com/liujiajia/comments/51714.html http://www.shnenglu.com/liujiajia/archive/2008/05/31/51714.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/51714.html http://www.shnenglu.com/liujiajia/services/trackbacks/51714.html
#include < iostream > #include< string > using namespace std; int main( void ) { string s1; // 鍒濆鍖栦負絀哄瓧絎︿覆 string s2( " hello " ); // 鍒濆鍖栦負涓涓瓧絎︿覆瀛楅潰鍓湰 string s3(s2); // 灝唖3鍒濆鍖栦負涓涓猻2鐨勫壇鏈?nbsp; string s4 = " hi jiajia " ; // 鍒濆鍖栦負涓涓瓧絎︿覆瀛楅潰鍓湰 string s5( 15 , ' A ' ); cout << s1 << endl << s2 << endl << s3 << endl << s4 << endl << s5 << endl; system( " pause " ); return 0 ; }
娉ㄦ剰錛氱敱浜庡巻鍙插師鍥犱互鍙婁負浜嗕笌C璇█鍏煎錛屽瓧絎︿覆瀛楅潰鍊間笌鏍囧噯搴搒tring綾誨瀷涓嶆槸鍚屼竴縐嶇被鍨嬨?
]]> 鍛藉悕絀洪棿鐨剈sing澹版槑 http://www.shnenglu.com/liujiajia/archive/2008/05/31/51713.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Sat, 31 May 2008 15:36:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/31/51713.html http://www.shnenglu.com/liujiajia/comments/51713.html http://www.shnenglu.com/liujiajia/archive/2008/05/31/51713.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/51713.html http://www.shnenglu.com/liujiajia/services/trackbacks/51713.html : : 鎿嶄綔絎︽槸浣滅敤鍩熻В鏋愮銆傚畠鐨勫惈涔夋槸鍙蟲搷浣滄暟鐨勫悕瀛楀彲浠ュ湪宸︽搷浣滄暟鐨勪綔鐢ㄥ煙涓壘鍒般俿td::cout 鐨勬剰鎬濇槸璇存墍闇鍚嶅瓧cin鏄湪鍛藉悕絀洪棿std涓畾涔夌殑銆傝繖縐嶇鍙峰紩鐢ㄦ爣鍑嗗簱鍚嶅瓧鐨勬柟寮忔槸闈炲父楹葷儲鐨勩?br> c++鎻愪緵浜嗕竴縐嶇畝鍗曠殑鏂瑰紡鏉ヤ嬌鐢ㄥ懡鍚嶇┖闂存垚鍛橈紝using澹版槑銆傝繖鏄竴縐嶆渶瀹夊叏鐨勬満鍒躲?br>
#include < string > #include< iostream > using std::cin; using std::endl; using std:: string ; int main( void ) { string s; // 姝g‘銆俿tring浣跨敤浜唘sing澹版槑 cin >> s; // 姝g‘銆俢in浣跨敤浜唘sing澹版槑 cout << s; // 閿欒銆俢out娌℃湁浣跨敤using澹版槑 std::cout << s << endl; // 姝g‘銆傛寚瀹氫簡鍛藉悕絀洪棿 system( " pause " ); return 0 ; }
鍛藉悕絀洪棿鎵╁睍錛?/strong> 鍦ㄦ爣鍑咰++浠ュ墠錛岄兘鏄敤#include<iostream.h>榪欐牱鐨勫啓娉曠殑錛屽洜涓鴻鍖呭惈榪涙潵鐨勫ご鏂囦歡鍚嶅氨鏄痠ostream.h銆傛爣鍑咰++寮曞叆浜嗗悕瀛楃┖闂寸殑姒傚康錛屽茍鎶奿ostream絳夋爣鍑嗗簱涓殑涓滀笢灝佽鍒頒簡std鍚嶅瓧絀洪棿涓紝鍚屾椂涓轟簡涓嶄笌鍘熸潵鐨勫ご鏂囦歡娣鋒穯錛岃瀹氭爣鍑咰++浣跨敤涓濂楁柊鐨勫ご鏂囦歡錛岃繖濂楀ご鏂囦歡鐨勬枃浠跺悕鍚庝笉鍔?h鎵╁睍鍚嶏紝濡俰ostream銆乻tring絳夌瓑錛屽茍涓旀妸鍘熸潵C鏍囧噯搴撶殑澶存枃浠朵篃閲嶆柊鍛藉悕錛屽鍘熸潵鐨剆tring.h灝辨敼鎴恈string(灝辨槸鎶?h鍘繪帀錛屽墠闈㈠姞涓婂瓧姣峜)錛屾墍浠ュご鏂囦歡鍖呭惈鐨勫啓娉曚篃灝卞彉鎴愪簡#include <iostream>銆? 騫朵笉鏄啓浜?include<iostream>灝卞繀欏葷敤using namespace std;鎴戜滑閫氬父榪欐牱鐨勫啓鐨勫師鍥犳槸涓轟簡涓涓嬪瓙鎶妔td鍚嶅瓧絀洪棿鐨勪笢涓滃叏閮ㄦ毚闇插埌鍏ㄥ眬鍩熶腑錛堝氨鍍忔槸鐩存帴鍖呭惈浜唅ostream.h榪欑娌℃湁鍚嶅瓧絀洪棿鐨勫ご鏂囦歡涓鏍鳳級錛屼嬌鏍囧噯C++搴撶敤璧鋒潵涓庝紶緇熺殑iostream.h涓鏍鋒柟渚褲傚鏋滀笉鐢╱sing namespace std;浣跨敤鏍囧噯搴撴椂灝卞緱鏃舵椂甯︿笂鍚嶅瓧絀洪棿鐨勫叏鍚嶏紝濡俿td::cout << "hello" << std::endl; #include "iostream"涓?include<iostream>鐨勫尯鍒細鍓嶈呭厛鍦ㄥ綋鍓嶇洰褰曟壘iostream鏂囦歡錛屾壘涓嶅埌鍐嶅幓緋葷粺澶存枃浠惰礬寰勬壘錛屽悗鑰呭弽涔嬨傚洜姝わ紝鍋氫負涓涓壇濂界殑涔犳儻錛屽湪鍖呭惈緋葷粺澶存枃浠舵椂灝介噺鐢?lt;>錛岃屽湪鍖呭惈鑷繁鐨勫伐紼嬩腑鐨勫ご鏂囦歡鏃剁敤""銆?
]]> 寮濮嬪涔燾++璇█ http://www.shnenglu.com/liujiajia/archive/2008/05/31/51710.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Sat, 31 May 2008 15:07:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/31/51710.html http://www.shnenglu.com/liujiajia/comments/51710.html http://www.shnenglu.com/liujiajia/archive/2008/05/31/51710.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/51710.html http://www.shnenglu.com/liujiajia/services/trackbacks/51710.html 鏈潵瀛︿範c灝辨槸涓轟簡瀛++鑰屽噯澶囩殑錛屼絾鏄劅瑙夎繘搴︽湁鐐規參浜嗭紝鐪嬩簡浜涘熀紜鐨勶紝鍑嗗瀛++浜嗐?br> 瀵筩++璇█鐨勫涔狅紝鎴戝皢鐢ㄩ偅鏈粡鍏哥殑銆奀++ Primer銆?涓枃鐗?銆傚彟澶栫紪杈戝櫒浣跨敤Dev-c++4.9.9.2銆? 鍙﹀錛岀敱浜庡C璇█鐨勫涔犲拰浠ュ墠C++鐨勪竴鐐瑰熀紜錛屾墍浠ラ夋嫨浜嗐奀++ Primer銆嬭繖鏈功銆備絾鏄紝濡傛灉娌℃湁榪欐柟闈㈢殑鍩虹錛屽緩璁湅銆奀++ Primer Plus銆嬭繖鏈功銆?
]]> sprint() 鏍煎紡鍖栧啓鍏ュ瓧絎︿覆 http://www.shnenglu.com/liujiajia/archive/2008/05/31/51655.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Fri, 30 May 2008 16:01:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/31/51655.html http://www.shnenglu.com/liujiajia/comments/51655.html http://www.shnenglu.com/liujiajia/archive/2008/05/31/51655.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/51655.html http://www.shnenglu.com/liujiajia/services/trackbacks/51655.html 紼嬪簭浠庤鍙栫敤鎴瘋緭鍏ョ殑firstname,lastname鍜宲rize,騫跺皢浠栦滑璇誨彇鐨勫兼寜鐓т竴瀹氭牸寮忓瓨鍌ㄥ埌鍙︿竴涓瓧絎︿覆鏁扮粍鍐呫?/p>
#include < stdio.h > #define MAX 20 int main( void ) { char first[MAX]; char last[MAX]; char formal[ 2 * MAX + 10 ]; double prize; puts( " Enter your first name " ); gets(first); puts( " Enter your last name " ); gets(last); puts( " Enter your prize money " ); scanf( " %lf " , & prize); sprintf (formal, " %s,%-19s:$%6.2f\n " ,last,first,prize); puts(formal); getchar(); getchar(); return 0 ; }
]]> strcpy() 澶嶅埗瀛楃涓?/title> http://www.shnenglu.com/liujiajia/archive/2008/05/30/51654.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Fri, 30 May 2008 15:57:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/30/51654.html http://www.shnenglu.com/liujiajia/comments/51654.html http://www.shnenglu.com/liujiajia/archive/2008/05/30/51654.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/51654.html http://www.shnenglu.com/liujiajia/services/trackbacks/51654.html
#include < stdio.h > #include< string .h > #define SIZE 40 #define LIM 5 int main( void ) { char qwords[LIM][SIZE]; char temp[SIZE]; int i = 0 ; while (i < LIM && gets(temp)) { strcpy (qwords[i],temp); i ++ ; } puts( " The list " ); for (i = 0 ;i < LIM;i ++ ) { puts(qwords[i]); } getchar(); return 0 ; }
]]> strcmp() 姣旇緝瀛楃涓茬殑鍐呭 http://www.shnenglu.com/liujiajia/archive/2008/05/30/51653.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Fri, 30 May 2008 15:48:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/30/51653.html http://www.shnenglu.com/liujiajia/comments/51653.html http://www.shnenglu.com/liujiajia/archive/2008/05/30/51653.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/51653.html http://www.shnenglu.com/liujiajia/services/trackbacks/51653.html
char try [10]; puts( " Who is 1+1? " ); gets( try ); while (strcmp ( try ,"2") != 0 ) { puts( " No,it's wrong.Try again. " ); gets( try ); } puts( " OK,That's right " );
涓嬮潰紼嬪簭璇存槑鍚勭鎯呭喌涓嬶紝strcmp()鐨勮繑鍥炲鹼細
printf( " strcmp(\ " a\ " ,\ " a\ " )=%d\n " ,strcmp( " a " , " a " )); printf( " strcmp(\ " a\ " ,\ " b\ " )=%d\n " ,strcmp( " a " , " b " )); printf( " strcmp(\ " b\ " ,\ " a\ " )=%d\n " ,strcmp( " b " , " a " )); printf( " strcmp(\ " a\ " ,\ " c\ " )=%d\n " ,strcmp( " a " , " c " )); printf( " strcmp(\ " c\ " ,\ " a\ " )=%d\n " ,strcmp( " c " , " a " )); printf( " strcmp(\ " abc\ " ,\ " abd\ " )=%d\n " ,strcmp( " abc " , " abd " )); printf( " strcmp(\ " abc\ " ,\ " abcd\ " )=%d\n " ,strcmp( " abc " , " abcd " )); printf( " strcmp(\ " abc\ " ,\ " abbd\ " )=%d\n " ,strcmp( " abc " , " abbd " ));
]]> strcat()鍑芥暟 http://www.shnenglu.com/liujiajia/archive/2008/05/27/51323.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Tue, 27 May 2008 12:12:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/27/51323.html http://www.shnenglu.com/liujiajia/comments/51323.html http://www.shnenglu.com/liujiajia/archive/2008/05/27/51323.html#Feedback 1 http://www.shnenglu.com/liujiajia/comments/commentRss/51323.html http://www.shnenglu.com/liujiajia/services/trackbacks/51323.html
#include < stdio.h > #include< string .h > int main( void ) { char string1[ 20 ]; char string2[] = " goodbye " ; gets(string1); strcat(string1,string2); puts(string2); puts(string1); getchar(); return 0 ; }
浠ヤ笂紼嬪簭灝唖tring2瀛楃涓茬殑鎷瘋礉鏀懼埌浜唖tring1鐨勭粨灝俱?br> 鍊煎緱娉ㄦ剰鐨勬槸錛宻tring1鍦ㄨ浣跨敤strcat()鍑芥暟涔嬪墠錛屽簲璇ユ槸宸茬粡鍒濆鍖栨垨鑰呭凡緇忓瓨鍌ㄤ簡涓涓瓧絎︿覆銆傚洜涓哄鏋滃瓧絎︿覆娌℃湁琚垵濮嬪寲錛宻tring1[]閲岄潰鍏冪礌鐨勫瓨鍌ㄦ槸涓涓查殢鏈哄箋俿trcat()闇瑕佹壘鍒皊tring1鐨勭粨灝撅紙絎竴涓嚭鐜扮殑'\0'錛?鐒跺悗鍘繪帀榪欎釜'0',鏈鍚庢妸string2[]鐨勬嫹璐濇斁鍒皊tring1[]鏈鍚庝竴涓肩殑鍚庨潰銆?
]]> 浣跨敤strlen()鑾峰緱瀛楃涓查暱搴?/title> http://www.shnenglu.com/liujiajia/archive/2008/05/27/51321.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Tue, 27 May 2008 11:32:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/27/51321.html http://www.shnenglu.com/liujiajia/comments/51321.html http://www.shnenglu.com/liujiajia/archive/2008/05/27/51321.html#Feedback 1 http://www.shnenglu.com/liujiajia/comments/commentRss/51321.html http://www.shnenglu.com/liujiajia/services/trackbacks/51321.html 浣滅敤錛氳繑鍥炲弬鏁頒腑瀛楃涓茬殑闀垮害銆?br> 浠ヤ笅浠g爜鏄竴涓埅鍙栧瓧絎︿覆鐨勪緥瀛愶細
#include < stdio.h > #include< string .h > void fit( char * , int ); int main( void ) { char msg[] = " Hello moto " ; puts(msg); fit(msg, 5 ); puts(msg); puts(msg + 6 ); getchar(); return 0 ; } void fit( char * string , int size) { if (strlen( string ) > size) { * ( string + size) = ' \0 ' ; } }
鎴彇鍓嶏細
H
e
l
l
o
space
m
o
t
o
\0
鎴彇鍚?br>
fit()鏄埅鍙栧瓧絎︿覆鐨勬柟娉曘傚鏋滃瓧絎︿覆鐨勯暱搴﹀ぇ浜庤鎴彇鐨勯暱搴︼紝閭d箞灝嗘寚鍚戣瀛楃涓茬殑鎸囬拡鍚戝悗縐誨姩size浣嶅悗錛屽皢鎸囬拡鎸囧悜鐨勫唴瀹圭疆涓?\0'錛屽嵆瀛楃涓茬粨鏉熴備絾string+size+1澶勪粛鐒跺瓨鍦ㄤ竴涓瓧絎︿覆銆?
]]> 瀛楃涓茬殑杈撳叆鍜岃緭鍑猴紙璁よ瘑gets()fgets()scanf()鍜宲uts()fputs()printf()錛?/title> http://www.shnenglu.com/liujiajia/archive/2008/05/27/51304.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Tue, 27 May 2008 10:03:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/27/51304.html http://www.shnenglu.com/liujiajia/comments/51304.html http://www.shnenglu.com/liujiajia/archive/2008/05/27/51304.html#Feedback 1 http://www.shnenglu.com/liujiajia/comments/commentRss/51304.html http://www.shnenglu.com/liujiajia/services/trackbacks/51304.html 瀛楃涓茶緭鍏ワ細 gets() char name[20]; printf("Hi,What's your name?\n"); gets(name); printf("Nice name %s",name); 瀹冧嬌鐢ㄤ竴涓湴鍧鎶婂瓧絎︿覆璧嬩簣name銆?br> char name[20]; char *p; printf("\nEn,What's your name?\n"); p=gets(name); printf("%s?Oh,Nice name %s\n",name,p); get()鐨勪唬鐮佷嬌鐢╮eturn 鍏抽敭瀛楄繑鍥炲瓧絎︿覆鐨勫湴鍧錛岀▼搴忔妸榪欎釜鍦板潃鍒嗛厤緇欐寚閽坧銆?br>fgets() fgets()鏄負鏂囦歡I/O鑰岃璁$殑錛屽鐞嗛敭鐩樿緭鍏ヤ笉鏄壒鍒柟渚褲?br> printf("\nHi,What's your name?\n"); p=fgets(name,20,stdin); printf("%s?Oh,Nice name %s\n",name,p); *fgets()鐨勭浜屼釜鍙傛暟璇存槑鏈澶ц鍏ョ殑瀛楃鏁般傚鏋滆繖涓弬鏁板間負n錛岄偅涔坒gets()灝變細璇誨彇鏈澶歯-1涓瓧絎︽垨璇誨畬涓涓崲琛岀涓烘銆備袱涓潯浠舵弧瓚充換鎰忎竴涓粨鏉熴?br>*fgets()璇誨彇鍒版崲琛岀錛屽氨浼氭妸瀹冨瓨鍒板瓧絎︿覆閲岋紝鑰屼笉鏄兂gets()閭f牱涓㈠純瀹冦?br>*fgets()鐨勭涓変釜鍙傛暟璇存槑璇誨摢涓枃浠躲備粠閿洏涓婅鏁版嵁鏃訛紝鍙互浣跨敤stdin(浠h〃standard input)浣滀負鍙傛暟銆?br>scanf() char name1[11], name2[11]; int count; printf("\nPlease write down 2 names...\n"); count=scanf("%5s %6s",name1,name2); printf("\nname1:%s\nname2:%s",name1,name2); scanf()鍏佽鎸囧畾杈撳叆瀛楃涓查暱搴︾瓑鏍煎紡銆備笂闈㈢殑紼嬪簭濡傛灉杈撳叆"liujiajia liujiajia",紼嬪簭灝嗚緭鍑?name1:liuji name2:liujia";瀛楃涓茶緭鍑猴細 puts() char str[15]="hello world"; const char *str2="HELLO WORLD"; puts(str); puts(str2); puts(&str[5]); puts(str2+2); puts()鏄劇ず瀛楃涓叉椂鑷姩鍦ㄥ叾鍚庢坊鍔犱竴涓崲琛岀銆?br>puts(&str[5]);灝嗚緭鍑轟粠str鐨勭鍏釜鍏冪礌寮濮嬪埌瀛楃涓茬粨鏉熴?br>puts(str2+2);灝嗚緭鍑轟粠str2鐨勫湴鍧鍚戝悗縐誨姩涓や釜瀛楃寮濮嬪埌瀛楃涓茬粨鏉熴?br>fputs() fputs(str,stdout); fputs(str2,stdout); fputs(&str[5],stdout); fputs(str2+2,stdout); *fputs()絎簩涓弬鏁拌〃紺鴻鍐欑殑鏂囦歡銆傚彲浠ヤ嬌鐢╯tdout(浠h〃standard output)浣滀負鍙傛暟銆?br>*fputs()涓嶈嚜鍔ㄨ緭鍑烘崲琛岀錛岃繖涓巔uts()涓嶅お鐩稿悓銆?br>printf() 榪欎釜涓嶇敤澶氳浜嗐?
]]> 鍒濇璁よ瘑鏁扮粍銆佹寚閽堝拰瀛楃涓插叧緋?/title> http://www.shnenglu.com/liujiajia/archive/2008/05/24/50913.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Fri, 23 May 2008 16:27:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/24/50913.html http://www.shnenglu.com/liujiajia/comments/50913.html http://www.shnenglu.com/liujiajia/archive/2008/05/24/50913.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/50913.html http://www.shnenglu.com/liujiajia/services/trackbacks/50913.html 瀛楃涓叉暟緇勫垵濮嬪寲錛?/span> (1)char arr[10]="HI"; 鍒濆鍖栧瓧絎︿覆鏁扮粍鏃訛紝緙栬瘧鍣ㄨ嚜鍔ㄥ皢瀛楃涓叉渶鍚庝竴涓瓧絎﹀悗闈㈠姞涓?\0',浠ヨ〃紺哄瓧絎︿覆鐨勭粨鏉熴?br>濡傛灉鏁扮粍鐨勫ぇ灝忓ぇ浜庡瓧絎︿覆鐨勯暱搴?1錛岄偅涔堟妸瀛楃涓茬粨鏉熷悗闈㈢殑鍏冪礌涔熼兘鍒濆鍖栦負'\0'; 鐪嬭繖孌電▼搴忥細 瀹氫箟涓涓ぇ灝忎負12鐨勫瓧絎︿覆鏁扮粍 char str1[12]="jiajia"; 璁╀竴涓猚har鍨嬬殑鎸囬拡鎸囧悜榪欎釜鏁扮粍 char *p1=str1; 杈撳嚭榪欎釜瀛楃涓?br> printf("%s\n\n",str1); 鍒╃敤鎸囬拡杈撳嚭榪欎釜瀛楃涓叉暟緇勪腑姣忎釜鍏冪礌鐨勫瓧絎︺佸瓧絎scii鍊箋佸瓧絎﹀瓨鍌ㄥ湴鍧 for(int i=0;i<12;i++) { printf("%c:%d:%p\n",*p1,*p1,p1); p1++; } 鍙互鐪嬪嚭錛屾暟緇勫厓绱犵殑鍚庡嚑浣嶉兘琚垵濮嬪寲鎴愪簡'\0';浣跨敤printf鎵撳嵃瀛楃涓叉暟緇勬椂錛岀▼搴忛亣鍒扮涓涓?\0'灝辯粨鏉熷瀛楃涓茬殑璇誨彇銆?br> 濡傛灉鏁扮粍鐨勫ぇ灝忓皬浜庡瓧絎︿覆鐨勯暱搴?1錛岀▼搴忓湪榪愯鏃跺彲鑳借鍑虹幇闂錛屾墍浠ュ簲褰撶‘淇濇暟緇勭殑澶у皬瑕佸ぇ浜庡瓧絎︿覆闀垮害鐨勫ぇ灝?1錛?br> 榪欐紼嬪簭鐨勫瓧絎︿覆闀垮害+1灝忎簬鏁扮粍鐨勫ぇ灝忥細 char str2[12]="hello jiajia"; char *p2=str2;
printf("\n\n\n%s\n\n",str2); for(int i=0;i<28;i++) { printf("%c:%d:%p\n",*p2,*p2,p2); p2++; } 浣跨敤printf鎵撳嵃瀛楃涓詫紝紼嬪簭闇瑕佹壘鍒?\0'鎵嶈兘緇撴潫璇誨彇錛岀粨鏋滄壘閬嶆暣涓暟緇勬病鏈夋壘鍒幫紝鍙湁緇х畫欏虹潃鍦板潃瀵繪壘錛屼竴鐩存壘鍒版煇涓湴鍧涓婄殑assii鏄?鐨勶紝瀛楃涓叉墠璇誨彇瀹屾瘯銆傛墍浠ユ湰孌電▼搴忓湪璇誨彇瀹?hello jiajia"涔嬪悗錛屽悗闈㈠彲鑳借繕浼氭湁鍑犱釜闅忔満鐨勫瓧絎︼紝灝辨槸鍥犱負瀛楃涓茬粓姝簬'\0'銆?br>(2)char arr[]="Hello World!"; 榪欑鍒濆鍖栨柟娉曚笉鐢ㄦ媴蹇冩暟緇勫ぇ灝忚繃灝忕殑鎯呭喌錛屾暟緇勭殑澶у皬鐢辯紪璇戝櫒鍐沖畾銆?br>(3)char arr[]={'H','e','e','l','o',' ','W','o','r','l','d','\0'}; 鍚岀浜岀鏂規硶緇撴灉鐩稿悓錛屼絾鏄劇劧瑕侀夯鐑﹁澶氥傚彟澶栵紝' '浠h〃絀烘牸錛宎scii鍊兼槸32錛?\0'浠h〃瀛楃涓茬粨鏉燂紝ascii鍊兼槸0錛?br>(4)char *p="Hello World"; 浣跨敤鏁扮粍鐨勬柟寮忓垵濮嬪寲銆傚悓鏁扮粍涓嶅悓涔嬪鍦ㄤ簬,p鏄竴涓彉閲忥紝鍙互鍋氶掑銆侀掑噺榪愮畻錛岃宎rr鏄暟緇勭殑棣栧湴鍧錛屾槸涓涓湴鍧甯擱噺錛屼笉鑳藉仛閫掑銆侀掑噺榪愮畻銆?br> char *name="liujiajia"; name[0]='L'; printf("\n%s\n",name); name[0]='L';榪欏彞浠g爜鍦ㄦ渶鏂扮殑c99鏍囧噯涓細寮曞彂紼嬪簭寮傚父銆傞渶瑕佹敞鎰忋?br> char *string="c programe"; char *string2; string2=string; //灝嗘寚閽坰tring鐨勫艱祴緇檚tring2 printf("\nstring=%s,&string=%p,string=%p\n",string,&string,string); printf("\nstring=%s,&string=%p,string=%p\n",string2,&string2,string2); 涓婇潰榪欐紼嬪簭鏈鍚庢樉紺猴紝鎸囬拡string鎵鎸囧悜鐨勫湴鍧鍜屾寚閽坰tring2鎵鎸囧悜鐨勫湴鍧鐩稿悓錛岃繖灝辮鏄庡畠浠寚鍚戠殑鏄唴瀛橀噷闈㈠悓涓涓瓧絎︿覆錛屼篃灝辨槸璇村瓧絎︿覆鏈韓騫舵病鏈夊鍒訛紝鑰屾槸浜х敓浜嗕竴涓寚鍚戝悓涓涓瓧絎︿覆鐨勬寚閽堛傝繖鏍風▼搴忕殑鏁堢巼浼氭洿鍔犵殑楂樸傚鏋滈渶瑕佸鍒跺瓧絎︿覆鍙互浣跨敤 strcpy() 鎴?strncpy()銆?br>
]]>鍑芥暟鍜屼簩緇存暟緇勭殑鏂拌璇?鍙傛暟鎸囧畾鏁扮粍絎簩緇村拰絎竴緇村ぇ灝? http://www.shnenglu.com/liujiajia/archive/2008/05/20/50581.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Tue, 20 May 2008 14:31:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/20/50581.html http://www.shnenglu.com/liujiajia/comments/50581.html http://www.shnenglu.com/liujiajia/archive/2008/05/20/50581.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/50581.html http://www.shnenglu.com/liujiajia/services/trackbacks/50581.html
#include < stdio.h > #define ROWS 3 #define COLS 4 void sum_rows( int arr[][COLS], int rows); int main( void ) { int junk[ROWS][COLS] = {{ 1 , 2 , 3 , 4 },{ 5 , 6 , 7 , 8 },{ 9 , 10 , 11 , 12 }}; sum_rows(junk,ROWS); // 姹傚嚭姣忚鐨勬暟鍊兼誨拰銆?nbsp; getchar(); return 0 ; } void sum_rows( int arr[][COLS], int rows) { int r,c,tot; for (r = 0 ;r < rows;r ++ ) { tot = 0 ; for (c = 0 ;c < COLS;c ++ ) { tot += arr[r][c]; } printf( " row%d,sum=%d\n " ,r,tot); } }
鎴戜滑閮界煡閬撲笂闈㈢殑浠g爜鍙互欏哄埄鎵ц錛?sum_rows()鐨勫艦鍙傛槸 int arr[][COLS],娌℃湁鎸囧畾鏁扮粍鐨勭涓緇村ぇ灝忋備絾鏄鎯充竴涓嬶紝濡傛灉涓嶆寚瀹氱浜岀淮鐨勫ぇ灝忥紝緇撴灉浼氭庢牱鍛紵 鎴戝啓浜嗕互涓嬩緥瀛愶細
#include < stdio.h > int sum2d( int arr[][], int row, int col); int main( void ) { int arr[3 ][4 ] = {{ 1 , 2,3,5 },{ 3 , 4,4,5 },{2,3,4,5}}; sum2d(arr,3 ,4 ); getchar(); return 0 ; } int sum2d( int arr[][], int row, int col) { for ( int i = 0 ;i < row;i ++ ) { for ( int j = 0 ;j < col;j ++ ) { printf( " %d " ,arr[i][j]); invalid use of array with unspecified bounds } } return 0 ; }
榪愯鍚庡彂鐜幫紝紼嬪簭鎶ラ敊浜嗭紝榪欐槸涓轟粈涔堝憿錛熺櫨鎬濅笉寰楀叾瑙o紝鍚庢潵璇鋒暀浜咰SDN涓婅佸ぇ浠傜粓浜庣◢寰紕鏄庣櫧浜嗙偣鍎褲傛垜鎯沖叿浣撳簲璇ヤ粠涓ゆ柟闈㈣瘉鏄庝負浠涔堜笂闈㈢殑紼嬪簭涓嶅彲琛屻?br>錛?錛変粠浜岀淮鏁扮粍鐨勫瓨鍌ㄦ柟寮忎笂錛氫簩緇存暟緇勫湪鍐呭瓨涓婃槸涓琛屼竴琛岃繛緇殑瀛樺偍鐨勩傚涓嬪浘錛?br>arr[3][4]
arr[0][0]
arr[0][1]
arr[0][2]
arr[0][3]
arr[1][0]
arr[1][1]
arr[1][2]
arr[1][3]
...
鍥犱負arr鏄繖涓暟緇勭殑棣栧湴鍧錛屾垜浠彲浠ョ煡閬揳rr[0][0]鐨勫湴鍧銆傚彧瑕佹垜浠煡閬揳rr[][4]涓暟緇勭浜岀淮鐨勫ぇ灝?#8216;4’錛屾垜浠氨鍙互鎵懼埌浠繪剰琛屽拰鍒楃殑鍦板潃銆俛ddress=arr+(rows-1)*4+cols銆備絾鏄鏋滀笉鐭ラ亾絎簩緇寸殑澶у皬錛岄偅涔堟潯浠跺氨涓嶅浜嗐傛墦涓涓瘮鏂癸紝灝嗚嫢騫蹭釜瀛︾敓鍒嗘垚姣忕粍11浜猴紝騫惰浠栦滑绔欐垚涓鎺掞紝榪欐椂鎴戜滑鍙互瀹氫綅鍑虹鍑犵粍鐨勭鍑犱釜瀛︾敓銆備絾濡傛灉涓嶇煡閬撴瘡緇?1涓漢錛岄偅涔堟垜浠樉鐒跺氨鏃犳硶瀹氫綅浜嗐?br> 錛?錛変粠鎸囬拡鐨勮搴︿笂鐪?榪欑鎬濊礬鎴戣繕鏄湁鐐硅糠緋?:澶у鍙互鍙傜湅榪欎釜甯栧瓙錛?a >http://topic.csdn.net/u/20080520/09/2122e210-5cf5-4b75-b31f-c2523b00cf53.html?575319732 鎭╋紝鐜板湪鏄秺瀛﹁秺榪鋒儜浜嗐傚懙鍛點?br>
]]> 鍑芥暟鍜屼簩緇存暟緇?/title> http://www.shnenglu.com/liujiajia/archive/2008/05/19/50446.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Mon, 19 May 2008 15:03:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/19/50446.html http://www.shnenglu.com/liujiajia/comments/50446.html http://www.shnenglu.com/liujiajia/archive/2008/05/19/50446.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/50446.html http://www.shnenglu.com/liujiajia/services/trackbacks/50446.html
#include < stdio.h > #define ROWS 3 #define COLS 4 void sum_rows( int arr[][COLS], int rows); void sum_cols( int [][COLS], int ); // 鍙互鐪佺暐鍚嶇О int sum2d( int ( * arr)[COLS], int rows); // 鍙︿竴縐嶈娉曞艦寮?/span>int main( void ) { int junk[ROWS][COLS] = {{ 1 , 2 , 3 , 4 },{ 5 , 6 , 7 , 8 },{ 9 , 10 , 11 , 12 }}; sum_rows(junk,ROWS); // 姹傚嚭姣忚鐨勬暟鍊兼誨拰銆?nbsp; printf( " \n " ); // 姹傚嚭姣忓垪鐨勬暟鍊兼誨拰銆?nbsp; sum_cols(junk,ROWS); // 姹傚嚭鍏ㄩ儴鏁板肩殑鎬誨拰銆?nbsp; printf( " \nthe sum of the junk is %d " ,sum2d(junk,ROWS)); getchar(); return 0 ; } void sum_rows( int arr[][COLS], int rows) { int r,c,tot; for (r = 0 ;r < rows;r ++ ) { tot = 0 ; for (c = 0 ;c < COLS;c ++ ) { tot += arr[r][c]; } printf( " row%d,sum=%d\n " ,r,tot); } } void sum_cols( int arr[][COLS], int rows) { int r,c,tot; for (c = 0 ;c < COLS;c ++ ) { tot = 0 ; for (r = 0 ;r < rows;r ++ ) { tot += arr[r][c]; } printf( " col%d,sum=%d\n " ,c,tot); } } int sum2d( int ( * arr)[COLS], int rows) { int r,c,tot = 0 ; for (r = 0 ;r < rows;r ++ ) { for (c = 0 ;c < COLS;c ++ ) { tot += arr[r][c]; } } return tot; }
]]> 鎸囬拡鍜屽緇存暟緇?/title> http://www.shnenglu.com/liujiajia/archive/2008/05/19/50440.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Mon, 19 May 2008 14:28:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/19/50440.html http://www.shnenglu.com/liujiajia/comments/50440.html http://www.shnenglu.com/liujiajia/archive/2008/05/19/50440.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/50440.html http://www.shnenglu.com/liujiajia/services/trackbacks/50440.html 涓銆佸緇存暟緇勫湴鍧鍜屾寚閽堢殑鍏崇郴 int arr2[4][2]={{1,2},{3,4},{5,6},{7,8}}; printf("arr2=%p,&arr2[0]=%p,arr2[0]=%p,&ar2r[0][0]=%p\n",arr2,&arr2[0],arr2[0],&arr2[0][0]);
arr[0][0] (1)
arr[1][0] (3)
arr[2][0] (5)
arr[3][0] (7)
arr[0][1] (2)
arr[1][1] (4)
arr[2][1] (6)
arr[3][1] (8)
涓婇潰鐨勭▼搴忕殑緇撴灉杈撳嚭绔熺劧閮戒竴鏍楓備負浠涔堝憿錛?br>棣栧厛 arr2 浠h〃鐨勬槸arr2鏁扮粍鐨勯鍦板潃錛屾墍浠?arr2鐨勫煎拰 arr2絎竴涓瓙鍏冪礌arr2[0]鐨勫湴鍧鐩稿悓錛屽嵆 &arr2[0]錛?br>arr2[0]鏄惈鏈変袱涓暣褰㈠厓绱犱竴緇存暟緇勭殑棣栧湴鍧錛屽嵆&arr2[0][0]鐨勫箋?br>綆鍗曠殑璇達細arr[0]鏄竴涓暣鏁板ぇ灝忓璞$殑鍦板潃錛宎rr2鏄袱涓暣鏁板ぇ灝忓璞$殑鍦板潃銆傚洜涓烘暣鏁板拰涓や釜鏁存暟緇勬垚鐨勬暟緇勫紑濮嬩簬鍚屼竴涓湴鍧錛屾墍浠?arr2 鍜?arr2[0] 鍏鋒湁鐩稿悓鐨勬暟鍊箋?br>浜屻佹寚閽堬紙鍦板潃錛夎繍綆楀拰澶氱淮鏁扮粍鐨勫叧緋?/strong> printf("arr2+1=%p,arr2[0]+1=%p\n",arr2+1,arr2[0]+1); 鐜板湪鎴戜滑鐭ラ亾錛宎rr2 鍜?arr2[0]鍏鋒湁鐩稿悓鐨勬暟鍊鹼紝浣嗘槸arr2+1鍜宎rr2[0]+1涓轟粈涔堟暟鍊間笉涓鏍峰憿錛熻繖鏄洜涓猴紝arr2鎸囧悜鐨勫璞″ぇ灝忔槸涓や釜int錛屽効arr2[0]鎵鎸囧悜鐨勫ぇ灝忔槸涓涓猧nt銆傛墍浠rr2+1鐨勫艱姣攁rr2[0]+1鐨勫煎涓涓猧nt澶у皬銆?br>涓夈佷嬌鐢?瀵瑰緇存暟緇勫彇鍊?/strong> 鍥犱負 arr2[0] 鏄?arr2[0][0]鐨勯鍦板潃錛屾墍浠?*(arr2[0])浠h〃瀛樺偍鍦╝rr2[0][0]鐨勫箋傚悓鏍鳳紝arr2鏄痑rr2[0]鐨勯鍦板潃錛?arr灝辨槸 arr2[0]鐨勫箋備絾鏄?arr2[0]涔熸槸涓涓湴鍧錛屽嵆&arr2[0][0],鍥犳*arr2鏄?&arr2[0][0]銆傛墍浠?*&arr2[0][0] 絳変環浜?**arr2銆?&arr2[0][0] 鍙互綆鍖栦負 arr2[0][0]銆傛墍浠?arr2[0][0]==**arr2銆?br>綆鑰岃█涔嬶細arr2鏄湴鍧鐨勫湴鍧錛屾墍浠ラ渶瑕佺粡榪囦袱嬈″彇鍊兼墠鑳藉彇鍒板叿浣撶殑鏁板箋?br> 瀛﹀畬榪欎釜鐭ヨ瘑鐐癸紝鎵嶅彂鐜板湪鎸囬拡紜疄寰堥毦鎳傘?br>
]]> 鎸囬拡鐨勫熀鏈繍綆?/title> http://www.shnenglu.com/liujiajia/archive/2008/05/19/50421.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Mon, 19 May 2008 11:08:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/19/50421.html http://www.shnenglu.com/liujiajia/comments/50421.html http://www.shnenglu.com/liujiajia/archive/2008/05/19/50421.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/50421.html http://www.shnenglu.com/liujiajia/services/trackbacks/50421.html 瀵規寚閽堝彲浠ヨ繘琛?strong>璧嬪?/strong>銆?strong>姹傚?/strong>鎴?strong>鍙栧?/strong>銆?strong>鍙栨寚閽堢殑鍦板潃銆?strong>灝嗕竴涓寚閽堝姞涓婁竴涓暣鏁?/strong>銆?strong>澧炲姞鎸囬拡鐨勫?/strong>銆?strong>姹傚樊鍊?/strong>鐨勬搷浣溿傝鍙傜湅浠ヤ笅浠g爜灞曠ず浜嗗嚑縐嶆儏褰細
#include < stdio.h > int main( void ) { int urn[ 5 ] = { 100 , 200 , 300 , 400 , 500 }; int * p1, * p2, * p3; p1 = urn; // 鎶婁竴涓湴鍧璧嬬粰鎸囬拡 p2 =& urn[ 2 ]; // 鍙栧緱urn[2]鐨勫湴鍧錛屽茍璧嬬粰涓涓寚閽?/span> printf( " 鏁扮粍鍚勪釜鍏冪礌鐨勫煎拰鍦板潃錛歕n " ); for ( int i = 0 ;i < 5 ;i ++ ) { printf( " urn[%d]=%d &urn[%d]=%p;\n " ,i,urn[i],i, & urn[i]); } printf( " \n鎸囬拡鎸囧悜鐨勫湴鍧,鎸囬拡鎸囧悜鍦板潃鐨勫?鎸囬拡鐨勫湴鍧\n " ); printf( " p1=%p ,*p1=%d ,&p1=%p " ,p1, * p1, & p1); printf( " \n鎸囬拡鍔犱笂鏁存暟鐨勬晥鏋?鎸囬拡+int!=鎸囬拡錛屾寚閽?int==鍦板潃)錛歕n " ); printf( " p1+4=%p,*(p1+4)=%d " ,p1 + 4 , * (p1 + 4 )); // printf("&(p1+4)=%p",&(p1+4)) // error:p1+4鏄竴涓湴鍧錛屼笉鑳藉鍏惰繘琛屽彇鍦板潃鎿嶄綔錛屼絾鍙互灝唒1+4璧嬬粰涓涓寚閽?nbsp; p1 ++ ; // p++==p1+1銆俻1+1鏄竴涓湴鍧錛屽皢p1+1璧嬬粰p1 printf( " \n鍦╬1++浠ュ悗錛歕np1=%p ,*p1=%d ,&p1=%p\n " ,p1, * p1, & p1); // 姹備袱涓寚閽堝樊鍊?nbsp; printf( " \np2=%p,p1=%p,p2-p1=%d\n " ,p2,p1,p2 - p1); getchar(); return 0 ; }
]]> 甯︽湁鏁扮粍綾誨瀷鍙傛暟鐨勫嚱鏁?/title> http://www.shnenglu.com/liujiajia/archive/2008/05/16/50110.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Fri, 16 May 2008 15:54:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/16/50110.html http://www.shnenglu.com/liujiajia/comments/50110.html http://www.shnenglu.com/liujiajia/archive/2008/05/16/50110.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/50110.html http://www.shnenglu.com/liujiajia/services/trackbacks/50110.html 浼犻掓暟緇勫弬鏁幫紝鍏舵牳蹇冨氨鏄紶閫掕鏁扮粍鐨勯鍦板潃銆傜劧鍚庡嚱鏁板啀閫氳繃鏁扮粍銆佹寚閽堢瓑錛岀敤璇ユ暟緇勭殑棣栧湴鍧鏋勯犱竴涓柊鐨勬暟緇勬垨鎸囬拡錛屽啀閫氳繃浼犻掕繃鏉ョ殑鏁扮粍澶у皬錛屽璇ユ暟緇勮繘琛屾搷浣溿?/p>
#include < stdio.h > #define SIZE 4 int sumbyarr( int a[], int n); int sumbypointer( int * p, int n); int sumbyaddress( int address, int n); int sumbypointer2(int *begin,int *end) int main( void ) { int arr[SIZE] = { 10 , 20 , 30 , 40 }; int sum1; // 浣跨敤鏁扮粍浣滀負褰㈠弬鎺ユ敹鏁扮粍 sum1 = sumbyarr(arr,SIZE); printf( " the total of the arr by array is:%d\n " ,sum1); // 浣跨敤鎸囬拡浣滀負褰㈠弬鎺ユ敹鏁扮粍 int sum2; sum2 = sumbypointer(arr,SIZE); printf( " the total of the arr by pointer is:%d\n " ,sum2); // 浣跨敤鍦板潃浣滀負褰㈠弬鎺ユ敹鏁扮粍 int sum3; sum3 = sumbyaddress(arr,SIZE); printf( " the total of the arr by address is:%d\n " ,sum3); //浣跨敤涓や釜鎸囬拡褰㈠弬鎺ユ敹 int sum4; sum4=sumbypointer2(arr,arr+SIZE); printf(" the total of the arr by pointer2 is:%d\n " ,sum4); getchar(); return 0 ; } int sumbyarr( int a[], int n) { int index; int total = 0 ; for (index = 0 ;index < n;index ++ ) { total += a[index]; } return total; } int sumbypointer( int * p, int n) { int index; int total = 0 ; for (index = 0 ;index < n;index ++ ,p ++ ) { total +=* p; } return total; } int sumbyaddress( int address, int n) { int * p = address; int index; int total = 0 ; for (index = 0 ;index < n;index ++ ,p ++ ) { total +=* p; } return total; } int sumbypointer2(int *begin,int *end) { int total=0; while(begin<end) { total+=*begin; begin++; } return total; }
浠ヤ笂浠g爜婕旂ず鎬庢牱瀹氫箟鏈夋暟緇勪綔涓哄弬鏁扮殑鍑芥暟銆?br>濡傛灉鏁扮粍浣滀負鍙傛暟浼犻掕繘鍏ユ煇涓嚱鏁幫紝騫朵笖鍦ㄨ繖涓嚱鏁頒腑鏀瑰彉浜嗘暟緇勫厓绱犵殑鍊鹼紝閭d箞紼嬪簭榪斿洖鍚庯紝榪欎釜鏁扮粍鍏冪礌鐨勫兼湁娌℃湁鏀瑰彉鍛紵 褰撶劧錛屽兼敼鍙樹簡錛屽洜涓烘暟緇勬槸閫氳繃鍦板潃浼犻掔殑錛屾敼鍙樹簡琚皟鍑芥暟涓暟緇勭殑鍊間篃灝辨剰鍛崇潃鍚屾椂鏀瑰彉浜嗕富璋冨嚱鏁頒腑鏁扮粍鐨勫箋傚洜涓哄畠浠殑鍦板潃鏄浉鍚岀殑銆?
]]> 璁よ瘑鏁扮粍鍜屾寚閽堢殑鍏崇郴 http://www.shnenglu.com/liujiajia/archive/2008/05/16/50097.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Fri, 16 May 2008 13:30:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/16/50097.html http://www.shnenglu.com/liujiajia/comments/50097.html http://www.shnenglu.com/liujiajia/archive/2008/05/16/50097.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/50097.html http://www.shnenglu.com/liujiajia/services/trackbacks/50097.html int arr[SIZE]={1,2,3,4}; int index; for(index=0;index<SIZE;index++) { printf("arr[%d]=%d address=%p\n",index,arr[index],arr+index); } int *p=arr; for(index=0;index<SIZE;index++) { printf("*(p+%d)=%d p+%d=%p\n",index,*(p+index),index,p+index); } getchar(); return 0; 浠ヤ笂浠g爜灞曠ず浜嗚鍙栨暟緇勪腑鍏冪礌鐨勪袱縐嶆柟寮忥紝絎竴縐嶆槸甯歌鐨勪嬌鐢ㄦ暟緇勪笅鏍囨潵璇誨彇銆傜浜岀鏂規硶鏄嬌鐢ㄦ寚閽堟潵璇誨彇鏁扮粍銆?br> 閫氳繃絎竴涓柟娉曚腑鎵撳嵃鍑烘潵鐨勫唴瀹癸紝鎴戜滑鍙互璁よ瘑鍒幫紝鏁扮粍鍚嶅叾瀹炲氨鏄繖涓暟緇勭殑棣栧湴鍧錛屽嵆錛歛rr=鏁扮粍棣栧湴鍧;arr+1:鏁扮粍絎簩涓厓绱犵殑鍦板潃錛沘rr+2錛氭暟緇勭涓変釜鍏冪礌鐨勫湴鍧錛屼互姝ょ被鎺ㄣ傘傘?br> 絎簩縐嶆柟娉曟垜浠嬌鐢ㄦ寚閽堣闂唬鏇夸簡鏁扮粍涓嬫爣璁塊棶錛屾垜浠皢 arr(鍗蟲暟緇勭殑棣栧湴鍧)璧嬪肩粰浜嗘寚閽?*p錛屾墍浠?p灝辯瓑浜巃rr鐨勯鍦板潃錛宲+1灝辯瓑浜巃rr鐨勪簩涓厓绱犵殑鍦板潃錛岄偅涔?p灝辯浉褰撲簬浜哸rr[0],*(p+1)灝辯浉褰撲簬arr[1]銆?br> 鎴戜滑浠庝腑鍙互寰楀嚭涓涓粨璁猴細鏁扮粍鏍囪瀹為檯涓婃槸涓縐嶅彉鐩鎬嬌鐢ㄦ寚閽堢殑褰㈠紡銆?
]]> 浜岀淮鏁扮粍綆鍗曚嬌鐢?/title> http://www.shnenglu.com/liujiajia/archive/2008/05/16/49998.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Thu, 15 May 2008 16:06:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/16/49998.html http://www.shnenglu.com/liujiajia/comments/49998.html http://www.shnenglu.com/liujiajia/archive/2008/05/16/49998.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/49998.html http://www.shnenglu.com/liujiajia/services/trackbacks/49998.html #include < stdio.h > #define PLAYER 4 #define MATCH 3 int main( void ) { // 灝?鍚嶇悆鍛樿繎涓夊満姣旇禌鐨勫緱鍒嗗垵濮嬪寲 int arrmark[MATCH][PLAYER] = { { 9 , 8 , 7 , 5 }, { 8 , 10 , 8 , 7 }, { 7 , 7 , 10 , 6 } }; // 杈撳嚭鍏蜂綋鎴愮嘩 int i,j; printf( " ***********Roony Ronaldo Kaka Grosso\n " ); for (i = 0 ;i < MATCH;i ++ ) { printf( " match%d: " ,i); for (j = 0 ;j < PLAYER;j ++ ) { printf( " %8d " ,arrmark[i][j]); } printf( " \n " ); } // 鎵撳嵃鎬誨垎 int temp = 0 ; printf( " total " ); for (i = 0 ;i < PLAYER;i ++ ) // 姹傛瘡涓悆鍛樼殑鎬誨垎 { for (j = 0 ;j < MATCH;j ++ ) { temp += arrmark[j][i]; } printf( " %d " ,temp); temp = 0 ; } getchar(); }
]]> 鎸囧畾鏁扮粍澶у皬 http://www.shnenglu.com/liujiajia/archive/2008/05/15/49996.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Thu, 15 May 2008 15:32:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/15/49996.html http://www.shnenglu.com/liujiajia/comments/49996.html http://www.shnenglu.com/liujiajia/archive/2008/05/15/49996.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/49996.html http://www.shnenglu.com/liujiajia/services/trackbacks/49996.html char arr[10]; //OK char arr2[1+2*7]; //OK char arr3[sizeof(char)+2]; //OK char arr4[-2]; //error 鏁扮粍澶у皬涓嶈兘浣跨敤璐熸暟 char arr5[0]; //鏍規嵁緙栬瘧鍣ㄤ笉鍚岋紝鏈夌殑緙栬瘧鍣ㄨ漿鎹負“arr5[]”,鏈夌殑緙栬瘧涓嶉氳繃銆?/span> char arr6[3.14]; //error char arr7[(int)3.14]; //寮哄埗杞崲涓篿nt int m=2; char arr9[m]; //c99鍓嶄笉鍏佽 娉ㄦ剰錛歝99鏍囧噯鍏佽浣跨敤鍙橀噺鎸囧畾鏁扮粍澶у皬銆?
]]> 璁よ瘑鏁扮粍涔嬫暟緇勭殑鍒濆鍖?/title> http://www.shnenglu.com/liujiajia/archive/2008/05/15/49994.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Thu, 15 May 2008 15:11:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/15/49994.html http://www.shnenglu.com/liujiajia/comments/49994.html http://www.shnenglu.com/liujiajia/archive/2008/05/15/49994.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/49994.html http://www.shnenglu.com/liujiajia/services/trackbacks/49994.html
#include < stdio.h > #define SIZE 4 int main( void ) { // 涓鑸垵濮嬪寲 int arr[SIZE] = { 1 , 2 , 3 , 4 }; int index; for (index = 0 ;index < SIZE;index ++ ) { arr[index] ++ ; printf( " arr[%d]=%d\n " ,index,arr[index]); } // 瀹氫箟騫跺垵濮嬪寲涓涓猚onst鏁扮粍銆傛暟緇勫唴鍏冪礌涓嶈兘淇敼 int const arr2[SIZE] = { 1 , 2 , 3 , 4 }; // 鏁扮粍涓嶅垵濮嬪寲錛屽厓绱犵殑鍊間負闅忔満鏁般?nbsp; int arr3[SIZE]; for (index = 0 ;index < SIZE;index ++ ) { printf( " arr3[%d]=%d\n " ,index,arr3[index]); } // 濡傛灉鍒濆鍖栨暟緇勪腑閮ㄥ垎鍏冪礌錛屽叾浠栧厓绱犲垯琚垵濮嬪寲涓? int arr4[SIZE] = { 1 , 2 }; for (index = 0 ;index < SIZE;index ++ ) { printf( " arr4[%d]=%d\n " ,index,arr4[index]); } // 鎸囧畾瑕佸垵濮嬪寲鐨勫厓绱?/span> int arr5[SIZE] = { 1 ,[ 2 ] = 3 ,[ 3 ] = 4 }; for (index = 0 ;index < SIZE;index ++ ) { printf( " arr5[%d]=%d\n " ,index,arr5[index]); } // 鏁扮粍鐨勫厓绱犱釜鏁頒笉鍥哄畾 int arr6[] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 }; printf( " sizeof arr6=%d,sizeof arr6[0]=%d\n " , sizeof arr6, sizeof arr6[ 0 ]); for (index = 0 ;index < sizeof arr6 / sizeof arr6[ 0 ];index ++ ) { printf( " arr6[%d]=%d\n " ,index,arr6[index]); } return 0 ; }
紼嬪簭榪愯緇撴灉鏄細 鎬庝箞鏍鳳紵鏁扮粍鐨勫垵濮嬪寲鏂瑰紡澶氱澶氭牱銆備絾瑕佺伒媧昏繍鐢ㄣ?
]]> 璁よ瘑sizeof http://www.shnenglu.com/liujiajia/archive/2008/05/15/49942.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Thu, 15 May 2008 08:01:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/15/49942.html http://www.shnenglu.com/liujiajia/comments/49942.html http://www.shnenglu.com/liujiajia/archive/2008/05/15/49942.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/49942.html http://www.shnenglu.com/liujiajia/services/trackbacks/49942.html 浠ヤ笅浠g爜婕旂ずsizeof鐢ㄦ硶錛?br>
#include < stdio.h > #include< stddef.h > #include < stdlib.h > int main( void ) { int i; printf( " sizeof(2008)=%d\n " , sizeof ( 2008 )); printf( " sizeof(i)=%d\n " , sizeof (i)); printf( " sizeof i=%d\n " , sizeof i); printf( " sizeof(int)=%d\n " , sizeof ( int )); // printf("sizeof int=%d\n",sizeof int); // sizeof int鍐欐硶閿欒錛?nbsp; printf( " sizeof(char)=%d\n " , sizeof ( char )); printf( " sizeof(float)=%d\n " , sizeof ( float )); printf( " sizeof(double)=%d\n " , sizeof ( double )); return 0 ; }
榪愯緇撴灉鏄劇ず錛?br> 鍙﹀錛宻izeof 鍙互搴旂敤浜庢暟緇勩佺粨鏋勭瓑鎯呭喌錛岃鍙傝冭繖綃囨枃绔狅細http://blog.chinaunix.net/u/20828/showart_438003.html
]]> 浣跨敤igoogle http://www.shnenglu.com/liujiajia/archive/2008/05/15/49882.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Wed, 14 May 2008 16:00:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/15/49882.html http://www.shnenglu.com/liujiajia/comments/49882.html http://www.shnenglu.com/liujiajia/archive/2008/05/15/49882.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/49882.html http://www.shnenglu.com/liujiajia/services/trackbacks/49882.html igoogle 銆傚彲浠ヨ嚜宸辨坊鍔爂oogle涓轟綘鎻愪緵鐨勫皬宸ュ叿鏉ョ粍鎴愪綘鐨勪富欏點傞噷闈㈡湁涓猤oogle鐪肩潧錛屾劅瑙夊緢濂界帺銆?br>鍙槸鎴戝悓鏃舵兂鎶婃垜涓浜涘父鐢ㄧ殑閾炬帴鏀捐繘鍘伙紝浣嗘槸igoogle騫舵病鏈夋彁渚涚浉鍏崇殑宸ュ叿錛屾庝箞鍔烇紵娌″叧緋伙紝google涓轟綘鎻愪緵浜嗗皬宸ュ叿寮鍙戠殑鎺ュ彛銆?br> 1.榪涘叆 igoogle 銆?br>2.鐐瑰嚮“娣誨姞鍐呭”閾炬帴銆?br>3.鐐瑰嚮“娣誨姞渚涚ǹ婧愭垨灝忓伐鍏?#8221;錛岃緭鍏?#8216;http://helloliukai.googlepages.com/hi.xml’ 鐐瑰嚮娣誨姞銆?br>4.鐒跺悗鍥炲埌棣栭〉錛屼綘鍙互鐪嬪埌浣犵殑igoogle涓婚〉涓婃坊鍔犱簡涓涓悕涓?#8216;hello world example’鐨勫皬宸ュ叿銆?br> 鍛靛懙錛屼綘鍙鎵撳紑http://helloliukai.googlepages.com/hi.xml 榪欎釜xml鏂囦歡灝變細鍙戠幇鍏朵腑鐨勯棶棰樹簡銆?br>igoogle閫氳繃瑙f瀽xml鏂囦歡鏉ュ悜鐢ㄦ埛灞曠ず灝忓伐鍏楓備綘鍙鎶?#8220;<![CDATA[Hello, world!]]>”涓殑“Hello, world!”鏇挎崲鎴愪換鎰廻tml鎴杍avascript浠g爜灝辮浜嗐傜劧鍚庢妸淇敼榪囩殑xml鏂囦歡涓婁紶鍒頒竴涓叕鍏辯殑絀洪棿閲岄潰灝辮浜嗐傛垜鐢ㄧ殑鍚屾牱鏄痝oogle鐨勪駭鍝侊紝Page Creator錛?a >http://pages.google.com/ 銆傚懙鍛點俫oogle鐨勪笢涓滅‘瀹炲緢澶氥?br>鍙﹀錛寈ml紜疄涔熷緢寮哄ぇ銆?br>http://code.google.com/intl/zh-CN/apis/gadgets/ 榪欓噷鏈塯oogle鐨勮祫婧愶紝鏈夋暀紼嬪拰灝忕紪杈戝櫒銆備絾鏁欑▼鎰熻宸茬粡榪囨湡浜嗭紝濂藉閲岄潰鐨勪唬鐮侀兘涓嶈兘鐢ㄣ傚彲浠ヤ嬌鐢ㄩ偅涓皬緙栬緫鍣ㄦ墦寮鍚勭妯℃澘銆?
]]> 璁よ瘑閫掑綊鍑芥暟 http://www.shnenglu.com/liujiajia/archive/2008/05/14/49769.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Tue, 13 May 2008 16:08:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/14/49769.html http://www.shnenglu.com/liujiajia/comments/49769.html http://www.shnenglu.com/liujiajia/archive/2008/05/14/49769.html#Feedback 0 http://www.shnenglu.com/liujiajia/comments/commentRss/49769.html http://www.shnenglu.com/liujiajia/services/trackbacks/49769.html #include < stdio.h > void testfunc( int ); int main( void ) { testfunc( 1 ); return 0 ; } void testfunc( int n) { printf( " Lv%d:%p\n " ,n, & n); // %p 鍦板潃鏄劇ず鏍煎紡 if (n < 4 ) { testfunc(n + 1 ); // testfunc()璋冪敤浜嗚嚜宸?/span> } printf( " 2Lv%d:%p\n " ,n, & n); }
浠ヤ笂鏄竴涓掑綊鐨勭ず渚嬨?br>testfunc()鍦ㄥ唴閮ㄨ皟鐢ㄤ簡鑷繁錛岃繖鏍風殑鍚庢灉鏄細鏆傛椂涓嶆墽琛屾渶鍚庨潰鐨?#8220;printf("2Lv%d:%p\n",n,&n);”錛岃屾槸灝?n+1浣滀負鍙傛暟璋冪敤浜嗚嚜宸憋紝榪欐牱閲嶅錛屾渶緇堢▼搴忕殑緇撴灉鏄細 (鏍規嵁鐢佃剳涓嶅悓錛屽湴鍧鍙兘鏈夋墍涓嶅悓) 紼嬪簭鍏蜂綋榪愯姝ラ錛?br>1.main()璋冪敤testfunc(1) 2.testfunc(1)鎵ц錛屾墦鍗?#8220;lv1:0022FF60”錛?022FF60鏄痭鐨勫湴鍧 3.n<4,鏉′歡鎴愮珛錛?nbsp;testfunc(1)璋冪敤testfunc(2) 4.testfunc(2)鎵ц錛屾墦鍗?#8220;lv1:0022FF40”,鍥犱負姝ゆ椂testfunc(2)鐨勫彉閲弉宸茬粡涓嶆槸testfunc(1)涓殑鍙橀噺n浜嗭紝鎵浠ュ湴鍧涓嶅悓銆傦紙鍑芥暟鐨勫弬鏁頒綔鐢ㄥ煙鍙湪褰撳墠鍑芥暟錛?br>5.n<4錛屾潯浠舵垚绔嬶紝testfunc(2)璋冪敤testfunc(3) 6.testfunc(3)鎵ц錛屾墦鍗?#8220;lv1:0022FF20” 7.n<4錛屾潯浠舵垚绔嬶紝testfunc(3)璋冪敤testfunc(4) 8.testfunc(4)鎵ц錛屾墦鍗?#8220;lv1:0022FF00” 9.n<4,鏉′歡涓嶆垚绔嬶紝鎵撳嵃“2lv1:0022FF00” 10.榪斿洖璋冪敤testfunc(4)鐨則estfunc(3),鎵撳嵃“2lv1:0022FF20” 11.榪斿洖璋冪敤testfunc(3)鐨則estfunc(2),鎵撳嵃“2lv1:0022FF40” 12.榪斿洖璋冪敤testfunc(2)鐨則estfunc(1),鎵撳嵃“2lv1:0022FF60” OK,榪欏氨鏄嚱鏁扮殑閫掑綊璋冪敤錛岄氫織鐨勮灝辨槸鍑芥暟鑷繁璋冪敤鑷繁銆備互鍓嶅鏃舵病鏈夊紕鏄庣櫧錛岀幇鍦ㄧ粓浜庡紕鏄庣櫧浜嗐?br>
]]> 璁よ瘑getchar()鍜宲utchar() http://www.shnenglu.com/liujiajia/archive/2008/05/09/49367.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Fri, 09 May 2008 14:55:00 GMT http://www.shnenglu.com/liujiajia/archive/2008/05/09/49367.html http://www.shnenglu.com/liujiajia/comments/49367.html http://www.shnenglu.com/liujiajia/archive/2008/05/09/49367.html#Feedback 2 http://www.shnenglu.com/liujiajia/comments/commentRss/49367.html http://www.shnenglu.com/liujiajia/services/trackbacks/49367.html ch=getchar(); 鍜?scanf("%c",&ch);鏄悓鏍風殑鏁堟灉銆?br> putchar()鍑芥暟鐢ㄦ潵鎵撳嵃瀹冪殑鍙傛暟銆?br>putchar(ch); 鍜?printf("%c",ch); 鏄悓鏍風殑鏁堟灉銆?br> 榪欎袱涓嚱鏁伴兘鍦?stdio.h 鏂囦歡涓畾涔変簡銆?
]]>
久久国产欧美日韩精品免费 |
久久国产精品久久 |
狠狠色伊人久久精品综合网 |
久久久久国产精品熟女影院 |
久久精品国产亚洲AV蜜臀色欲 |
久久亚洲中文字幕精品一区四 |
99久久精品免费国产大片 |
久久国产精品-国产精品 |
国产精品久久国产精品99盘 |
国产91色综合久久免费 |
99久久99这里只有免费费精品 |
亚洲国产精品无码久久98 |
狠狠色婷婷久久综合频道日韩 |
久久久久亚洲精品日久生情 |
久久狠狠爱亚洲综合影院 |
久久久久久国产精品无码下载
|
国产69精品久久久久观看软件 |
亚洲精品综合久久 |
久久久久久午夜精品 |
伊人久久综合成人网 |
久久精品a亚洲国产v高清不卡 |
99久久国产热无码精品免费 |
一本大道加勒比久久综合 |
精品久久人人做人人爽综合 |
污污内射久久一区二区欧美日韩
|
国产精品久久久久久 |
97精品伊人久久久大香线蕉 |
久久99精品久久久久久不卡
|
久久久精品2019免费观看 |
久久777国产线看观看精品 |
国产成人久久777777 |
热综合一本伊人久久精品 |
三级三级久久三级久久 |
国内精品久久久久影院一蜜桃 |
欧美精品一区二区精品久久 |
久久天天躁狠狠躁夜夜2020 |
欧美精品国产综合久久 |
久久国产精品一区二区 |
久久伊人五月天论坛 |
奇米综合四色77777久久 |
国产精品久久久久久久久久免费 |