锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久亚洲sm情趣捆绑调教,亚洲国产精品18久久久久久,久久精品中文字幕无码绿巨人http://www.shnenglu.com/liujiajia/瀛︿範銆佸伐浣溿佺敓媧伙紝榪欐槸涓変釜闂銆?/description>zh-cnThu, 08 May 2025 16:28:01 GMTThu, 08 May 2025 16:28:01 GMT60鏈綆鍗曠殑windows紼嬪簭http://www.shnenglu.com/liujiajia/archive/2008/07/23/56963.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Wed, 23 Jul 2008 09:01:00 GMThttp://www.shnenglu.com/liujiajia/archive/2008/07/23/56963.htmlhttp://www.shnenglu.com/liujiajia/comments/56963.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/07/23/56963.html#Feedback3http://www.shnenglu.com/liujiajia/comments/commentRss/56963.htmlhttp://www.shnenglu.com/liujiajia/services/trackbacks/56963.html1.鎵撳紑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 GMThttp://www.shnenglu.com/liujiajia/archive/2008/07/16/56244.htmlhttp://www.shnenglu.com/liujiajia/comments/56244.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/07/16/56244.html#Feedback2http://www.shnenglu.com/liujiajia/comments/commentRss/56244.htmlhttp://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><link>http://www.shnenglu.com/liujiajia/archive/2008/07/15/56143.html</link><dc:creator>鍒樺姞鍔?/dc:creator><author>鍒樺姞鍔?/author><pubDate>Mon, 14 Jul 2008 16:05:00 GMT</pubDate><guid>http://www.shnenglu.com/liujiajia/archive/2008/07/15/56143.html</guid><wfw:comment>http://www.shnenglu.com/liujiajia/comments/56143.html</wfw:comment><comments>http://www.shnenglu.com/liujiajia/archive/2008/07/15/56143.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/liujiajia/comments/commentRss/56143.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/liujiajia/services/trackbacks/56143.html</trackback:ping><description><![CDATA[      鏁扮粍鏈変袱涓壒孌婄殑鎬ц川錛屽獎鍝嶆垜浠畾涔夊拰浣跨敤浣滅敤鍦ㄦ暟緇勪笂鐨勫嚱鏁幫細涓鏄笉鑳藉鍒舵暟緇勩備簩鏄嬌鐢ㄦ暟緇勫悕瀛楁椂錛屾暟緇勪細鑷姩杞崲涓烘寚鍚戝叾絎竴涓厓绱犵殑鎸囬拡銆傚洜涓烘暟緇勪笉鑳藉鍒訛紝鎵浠ユ棤娉曠紪鍐欎嬌鐢ㄦ暟緇勭被鍨嬪艦鍙傜殑鍑芥暟銆傚洜涓烘暟緇勪細琚垵濮嬪寲涓烘寚閽堬紝鎵浠ュ鐞嗘暟緇勭殑鍑芥暟閫氬父閫氳繃鎿嶄綔鎸囧悜鏁扮粍涓殑鍏冪礌鐨勬寚閽堟潵澶勭悊鏁扮粍銆?br><br>紺轟緥錛?br><br>      //褰㈠紡1<br>      void printValues(const int ia[10])     //铏界劧褰㈠弬鎸囧畾浜嗘暟緇勭殑澶у皬錛屼絾緙栬瘧鏃朵笉浼氭鏌ュ疄鍙傛暟緇勫ぇ灝忥紝鍥犱負緙栬瘧鍣ㄥ彧媯鏌ュ艦鍙傛槸鍚︽槸鎸囬拡錛屽茍涓旀寚閽堢被鍨嬪拰鏁扮粍鍏冪礌鐨勭被鍨嬫槸鍚﹀尮閰嶃?br>      {<br>             for(size_t i=0;i!=10;i++)<br>             {<br>                    cout<<ia[i]<<endl; <br>             }<br>      }<br>      //褰㈠紡2<br>      void printValues2(const int ia[],int size)<br>      {<br>             for(size_t i=0;i!=size;i++)<br>             {<br>                    cout<<ia[i]<<endl; <br>             }<br>      }<br>      int main(void)<br>      {<br>            int i[10]={1,2,3,4,5,6,7,8,9,0};<br>            printValues(i);   //i浣滀負printValues鐨勫疄鍙傦紝鍦ㄨ繖閲屼負鏁扮粍i鐨勯鍦板潃錛屾垨鑰呰浠栬漿鎹負鎴愪竴涓寚閽?br>            printValues2(i,10);<br>      }<br><br>      鏁扮粍褰㈠弬鍙互瀹氫箟涓哄紩鐢ㄦ垨闈炲紩鐢ㄧ被鍨嬨傚ぇ閮ㄥ垎鎯呭喌涓嬶紝鏁扮粍浠ユ櫘閫氱殑闈炲紩鐢ㄧ被鍨嬩紶閫?姝ゆ椂鏁扮粍浼氭倓鎮勭殑杞崲涓烘寚閽堛備竴鑸潵璇達紝闈炲紩鐢ㄧ被鍨嬬殑褰㈠弬浼氬垵濮嬪寲涓哄叾鐩稿簲瀹炲弬鐨勫壇鏈備絾鏄湪浼犻掓暟緇勬椂錛屽疄鍙傛槸鎸囧悜鏁扮粍絎竴涓厓绱犵殑鎸囬拡錛屽艦鍙傚鍒剁殑鏄繖涓寚閽堢殑鍊鹼紝鑰屼笉鏄暟緇勫厓绱犳湰韜傚嚱鏁版搷浣滅殑涔熸槸鎸囬拡鐨勫壇鏈紝鍥犳涓嶄細淇敼瀹炲弬鎸囬拡鐨勫箋傜劧鑰岋紝鍑芥暟鍙氳繃璇ユ寚閽堜慨鏀瑰畠鎵鎸囧悜鐨勬暟緇勫厓绱犵殑鍊箋?br><br>浠ヤ笂浠g爜鍙互浣跨敤鎸囬拡琛ㄧず錛屾晥鏋滅瓑鍚岋細<br><br>      void printValues3(const int *ia,int size)<br>      {<br>             for(size_t i=0;i!=size;i++,ia++)<br>             {<br>                 cout<<*ia<<endl; <br>             }<br>       }<br><br><br>紺轟緥2錛堥氳繃寮曠敤浼犻掓暟緇勶級錛?br><br>      void printValues4(int (&arr)[10])    //榪欑鎯呭喌涓嬶紝鏁扮粍澶у皬鎴愪負褰㈠弬鍜屽疄鍙傜殑涓閮ㄥ垎銆傜紪璇戝櫒浼氭鏌ユ暟緇勫ぇ灝忔槸鍚﹀尮閰嶃?nbsp;int (&arr)[10] 涓殑灝忔嫭鍙鋒槸蹇呴』鐨勩?br>      {<br>          for(size_t i=0;i!=10;i++)<br>          {<br>                 cout<<arr[i]<<endl; <br>          }<br>      }<br>      int main(void)<br>      {<br>            printValues4(i);<br>      }<br><br>      鍜屽叾浠栫被鍨嬩竴鏍鳳紝鏁扮粍褰㈠弬鍙0鏄庝負鏁扮粍鐨勫紩鐢ㄣ傚鏋滃艦鍙傛槸鏁扮粍鐨勫紩鐢紝緙栬瘧鍣ㄤ笉浼氬皢鏁扮粍瀹炲弬杞寲涓烘寚閽堬紝鑰屾槸浼犻掓暟緇勭殑寮曠敤鏈韓銆? <img src ="http://www.shnenglu.com/liujiajia/aggbug/56143.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/liujiajia/" target="_blank">鍒樺姞鍔?/a> 2008-07-15 00:05 <a href="http://www.shnenglu.com/liujiajia/archive/2008/07/15/56143.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>浼犻掓寚鍚戞寚閽堢殑寮曠敤http://www.shnenglu.com/liujiajia/archive/2008/07/14/56135.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Mon, 14 Jul 2008 14:19:00 GMThttp://www.shnenglu.com/liujiajia/archive/2008/07/14/56135.htmlhttp://www.shnenglu.com/liujiajia/comments/56135.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/07/14/56135.html#Feedback0http://www.shnenglu.com/liujiajia/comments/commentRss/56135.htmlhttp://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 GMThttp://www.shnenglu.com/liujiajia/archive/2008/07/14/56131.htmlhttp://www.shnenglu.com/liujiajia/comments/56131.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/07/14/56131.html#Feedback0http://www.shnenglu.com/liujiajia/comments/commentRss/56131.htmlhttp://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><link>http://www.shnenglu.com/liujiajia/archive/2008/07/14/56085.html</link><dc:creator>鍒樺姞鍔?/dc:creator><author>鍒樺姞鍔?/author><pubDate>Mon, 14 Jul 2008 04:12:00 GMT</pubDate><guid>http://www.shnenglu.com/liujiajia/archive/2008/07/14/56085.html</guid><wfw:comment>http://www.shnenglu.com/liujiajia/comments/56085.html</wfw:comment><comments>http://www.shnenglu.com/liujiajia/archive/2008/07/14/56085.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.shnenglu.com/liujiajia/comments/commentRss/56085.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/liujiajia/services/trackbacks/56085.html</trackback:ping><description><![CDATA[      涓涓嚱鏁板彧鑳芥湁涓涓繑鍥炲鹼紝浣嗗鏋滄垜鎯寵浠栬繑鍥炴洿澶氱殑淇℃伅鎬庝箞鍔炲憿錛熻繖縐嶆儏鍐靛彲浠ヤ嬌鐢ㄥ紩鐢ㄥ艦鍙傘?br>      鍥犱負寮曠敤褰㈠弬鍦ㄥ嚱鏁拌皟鐢ㄥ悗鏄彲浠ヤ慨鏀瑰疄鍙傚肩殑錛屾墍浠ュ氨鐩稿綋涓庡嚱鏁扮殑榪斿洖鍊箋?br><br>      涓嬮潰鐨勪唬鐮佹紨紺轟簡涓涓甫鏈変竴涓繑鍥炲鹼紝騫墮氳繃寮曠敤褰㈠弬鍚戜富璋冨嚱鏁拌繑鍥炰俊鎭殑鍑芥暟銆傝繖涓嚱鏁扮殑鍔熻兘鏄壘鍑哄湪瀹瑰櫒涓煇涓涓暟鍊煎嚭鐜扮殑嬈℃暟錛屽茍榪斿洖璇ユ暟鍊肩涓嬈″嚭鐜扮殑榪唬鍣ㄣ?br><br><br> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008000">//</span><span style="COLOR: #008000">liujiajia<br></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">2008-7-14</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br>#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">vector</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000"> std;<br>vector</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">::const_iterator find_val(vector</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">::const_iterator,vector</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">::const_iterator,</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">,vector</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">::size_type </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">);<br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main(</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">)<br>{<br>    vector</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> some;<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> val;<br>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">浣跨敤push_back()杈撳叆瀹瑰櫒涓殑鍊?nbsp;</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(cin</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">val)<br>    {<br>        some.push_back(val);<br>    }<br>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">瀛樺偍鍊煎嚭鐜扮殑嬈℃暟 </span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    vector</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">::size_type ccurs;<br>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">璋冪敤鍑芥暟 </span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    vector</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">::const_iterator it</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">find_val(some.begin(),some.end(),</span><span style="COLOR: #000000">8</span><span style="COLOR: #000000">,ccurs);<br>    <br>    cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">ccurs</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br>    <br>    getchar();<br>}<br><br>vector</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">::const_iterator find_val(<br>    vector</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">::const_iterator beg,<br>    vector</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">::const_iterator end,<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> value,<br>    vector</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">::size_type </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">occurs)<br>{<br>    vector</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">::const_iterator res_iter</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">end;<br>    occurs</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(;beg</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">end;</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">beg)<br>    {<br>        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">beg</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">value)<br>        {<br>            </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">榪欎釜if璇彞鐨勪綔鐢ㄦ槸璁﹔es_iter絳変簬鍊肩涓嬈″嚭鐜扮殑浣嶇疆 </span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">            </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(res_iter</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">end)<br>            {<br>                res_iter</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">beg;<br>            }<br>            occurs</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br>        }<br>    }<br>    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> res_iter;<br>}</span></div> <br><br>       <img src ="http://www.shnenglu.com/liujiajia/aggbug/56085.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/liujiajia/" target="_blank">鍒樺姞鍔?/a> 2008-07-14 12:12 <a href="http://www.shnenglu.com/liujiajia/archive/2008/07/14/56085.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍑芥暟鐨勫艦鍙傦紙闈炲紩鐢ㄥ艦鍙傘佹寚閽堝艦鍙傘佸紩鐢ㄥ艦鍙傦級http://www.shnenglu.com/liujiajia/archive/2008/07/14/56054.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Sun, 13 Jul 2008 16:30:00 GMThttp://www.shnenglu.com/liujiajia/archive/2008/07/14/56054.htmlhttp://www.shnenglu.com/liujiajia/comments/56054.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/07/14/56054.html#Feedback2http://www.shnenglu.com/liujiajia/comments/commentRss/56054.htmlhttp://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><link>http://www.shnenglu.com/liujiajia/archive/2008/07/12/55984.html</link><dc:creator>鍒樺姞鍔?/dc:creator><author>鍒樺姞鍔?/author><pubDate>Sat, 12 Jul 2008 15:26:00 GMT</pubDate><guid>http://www.shnenglu.com/liujiajia/archive/2008/07/12/55984.html</guid><wfw:comment>http://www.shnenglu.com/liujiajia/comments/55984.html</wfw:comment><comments>http://www.shnenglu.com/liujiajia/archive/2008/07/12/55984.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/liujiajia/comments/commentRss/55984.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/liujiajia/services/trackbacks/55984.html</trackback:ping><description><![CDATA[      鍔ㄦ佹暟緇勶紝欏懼悕鎬濅箟錛屽氨鏄彲浠ュ姩鎬佸垎閰嶉暱搴︾殑鏁扮粍銆傚湪c璇█涓紝鏁扮粍鐨勯暱搴︽槸鍥哄畾鐨勶紝鑰岃繖縐嶉檺鍒舵樉鐒舵槸寰堜笉鐏墊椿鐨勩傚湪c++涓紝鏁扮粍鏈夋椂鍊欎笉鐢ㄥ湪緙栬瘧鏃跺氨鐭ラ亾闀垮害錛岀洿鍒拌繍琛屾椂鎵嶇煡閬撱備笌鏅氱殑鏁扮粍鍙橀噺涓嶅悓錛屽姩鎬佸垎閰嶇殑鏁扮粍灝嗕竴鐩村瓨鍦紝鐩村埌紼嬪簭鏄懼紡鐨勯噴鏀懼畠涓烘銆?br><br><strong style="FONT-SIZE: 14pt">瀹氫箟錛?/strong><br><br>      int *p=new int[20];<br><br>      p灝辨槸涓涓姩鎬佹暟緇勶紝榪欐椂鎴戜滑鍙戠幇錛屽叾瀹炴墍璋撶殑鍔ㄦ佹暟緇勫氨鏄竴涓寚閽堬紝浣跨敤new涓簆鍒嗛厤闀垮害銆傛垜浠彲浠ラ氳繃榪欑鏂瑰紡鍒濆鍖栵細 int *p=new int[20]();<br><br>      鍚屾牱涓婇潰鐨勮鍙ョ瓑鍚屼簬錛?br>      int n=20; <br>      int *p=new int[n];<br>      鍥犱負n鏄竴涓彉閲忥紝鎵浠ユ暟緇勭殑闀垮害鏄姩鎬佺殑銆?br><br><strong style="FONT-SIZE: 14pt">鎿嶄綔瀹炰緥錛?/strong><br><br>      int n=20; <br>      int *p=new int[n];<br><br>      p鍙互浣跨敤鏁扮粍涓嬫爣涓哄叾璧嬪鹼細<br>      for(int i=0;i<n;i++)<br>      {<br>            p[i]=i+3;<br>      }<br>     涓婇潰榪欑鏂瑰紡娌℃湁闂錛屼絾鎴戞兂鏃㈢劧p鏄竴涓寚閽堬紝閭d箞浣跨敤鎸囬拡鎿嶄綔涓鏍蜂篃鍙互鍚э紵<br><br>     for(int i=0;i<n;i++,p++)<br>    {<br>           *p=i;<br>     }<br> <br>      榪欐牱灝卞彲浠ヤ簡錛屽皢浠栦滑杈撳嚭錛氾紙榪欐椂鎸囬拡p鍙堟寚鍚戜簡鏈鍚庯級<br>      <br>      p--;<br>      for(int *p2=p-10;p2!=p;p--)<br>      {<br>           cout<<*p<<endl;<br>      }<br><br><span style="FONT-SIZE: 14pt"><strong>鍔ㄦ佺┖闂撮噴鏀撅細</strong></span><br><br>      鏈鍚庨噸瑕佺殑鏄埆蹇樹簡灝嗗姩鎬佸垱閫犵殑絀洪棿閲婃斁鎺夛紝璇彞鏄細delete [] p;   ‘[ ]’琛ㄦ槑璇ユ寚閽堟槸鎸囧悜鐨勮嚜鐢卞瓨鍌ㄥ尯鐨勬暟緇勶紝鑰岄潪鍗曚釜瀵硅薄銆傚鏋滈仐婕忎簡絀烘柟鎷彿錛岀紪璇戝櫒灝嗘棤娉曞彂鐜拌繖涓敊璇紝灝嗗鑷寸▼搴忓湪榪愯鏃跺嚭閿欍?br><br>瀹屾垚浜嗭紒浠ヤ笅鏄畬鏁翠唬鐮侊細<br><br> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000"> std;<br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main(</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">)<br>{<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> n</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">20</span><span style="COLOR: #000000">;<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">=</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">[n];<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">n;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">,p</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>    {<br>        cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br>        </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">i;<br>    }<br>    p</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">;<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">p2</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">n;p2</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">p;p</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">)<br>    {<br>        cout</span><span style="COLOR: #000000"><<*</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br>    }<br>    <br>    delete [] p;<br>    <br>    getchar();<br>}</span></div> <br> <img src ="http://www.shnenglu.com/liujiajia/aggbug/55984.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/liujiajia/" target="_blank">鍒樺姞鍔?/a> 2008-07-12 23:26 <a href="http://www.shnenglu.com/liujiajia/archive/2008/07/12/55984.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>const鍜屾寚閽堬紙鎸囧悜const瀵硅薄鐨勬寚閽堛乧onst鎸囬拡錛?/title><link>http://www.shnenglu.com/liujiajia/archive/2008/06/21/54166.html</link><dc:creator>鍒樺姞鍔?/dc:creator><author>鍒樺姞鍔?/author><pubDate>Fri, 20 Jun 2008 16:13:00 GMT</pubDate><guid>http://www.shnenglu.com/liujiajia/archive/2008/06/21/54166.html</guid><wfw:comment>http://www.shnenglu.com/liujiajia/comments/54166.html</wfw:comment><comments>http://www.shnenglu.com/liujiajia/archive/2008/06/21/54166.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/liujiajia/comments/commentRss/54166.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/liujiajia/services/trackbacks/54166.html</trackback:ping><description><![CDATA[<span style="FONT-SIZE: 14pt"><strong>1.鎸囧悜const瀵硅薄鐨勬寚閽?/strong></span><br><br>const int *p;<br>榪欎釜p鏄竴涓寚鍚慽nt綾誨瀷const瀵硅薄鐨勬寚閽堬紝const闄愬畾浜嗘寚閽坧鎵鎸囧悜鐨勭被鍨嬶紝鑰屽茍闈瀙鏈韓銆備篃灝辨槸璇磒鏈韓騫朵笉鏄痗onst銆傚湪瀹氫箟鏃朵笉闇瑕佸瀹冭繘琛屽垵濮嬪寲錛岃繕鍙互緇檖閲嶆柊璧嬪鹼紝浣垮叾鎸囧悜鍙︿竴涓猚onst瀵硅薄銆備絾涓嶈兘閫氳繃p淇敼鎵鎸囧悜瀵硅薄鐨勫箋?br>紺轟緥1錛歩nt a=0; p=&a;  鍙互銆?br>紺轟緥2錛?p=20;  涓嶅彲浠ャ?br>緇撹錛氳繖縐嶆寚鍚慶onst瀵硅薄鐨勬寚閽堝彧鏄檺鍒朵笉鑳戒慨鏀筽鎸囧悜瀵硅薄鐨勬暟鍊鹼紝鑰屼笉鏄檺鍒秔鎸囧悜浠涔堝璞°?br><br>鎶婁竴涓猚onst瀵硅薄鐨勫湴鍧璧嬬粰涓涓笉鏄寚鍚慶onst瀵硅薄鐨勬寚閽堜篃鏄笉琛岀殑銆?br>紺轟緥3錛歝onst int b=10;<br>               int *p2=&b;   //error<br>               const int *p3=&b; //ok<br>緇撹錛氬洜涓哄彉閲廱鏈塩onst淇グ錛屼笉鑳借淇敼銆備絾鎸囬拡p2鏄竴涓櫘閫氱殑鎸囬拡錛屽彲浠ヤ慨鏀規寚鍚戝璞$殑鍊鹼紝涓ょ澹版槑鐭涚浘錛屾墍浠ヤ笉鍚堟硶銆傝屾寚鍚慶onst瀵硅薄鐨勬寚閽堜笉鍏佽淇敼鎸囬拡鎸囧悜瀵硅薄鐨勬暟鍊鹼紝鎵浠ヨ繖縐嶆柟寮忓悎娉曘?br><br><span style="FONT-SIZE: 14pt"><strong>2.const鎸囬拡</strong></span><br><br>int c=20;<br>int *const p4=&c;<br><br>鎸囬拡p4縐頒負const鎸囬拡銆傚畠鍜屾寚鍚慶onst瀵硅薄鐨勬寚閽堟伆濂界浉鍙嶏紝瀹冧笉鑳藉淇敼鎵鎸囧悜瀵硅薄錛屼絾鍗磋兘澶熶慨鏀規寚鍚戝璞$殑鏁板箋傚彟澶栵紝榪欑鎸囬拡鍦ㄥ0鏄庢椂蹇呴』鍒濆鍖栥?br><br><span style="FONT-SIZE: 14pt"><strong>3.鎸囧悜const瀵硅薄鐨刢onst鎸囬拡</strong></span><br><br>const int d=30;<br>const int *const dp=&d;<br><br>鎸囬拡dp鏃笉鑳戒慨鏀規寚鍚戠殑瀵硅薄錛屼篃涓嶈兘淇敼鍙兂瀵硅薄鐨勫箋? <img src ="http://www.shnenglu.com/liujiajia/aggbug/54166.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/liujiajia/" target="_blank">鍒樺姞鍔?/a> 2008-06-21 00:13 <a href="http://www.shnenglu.com/liujiajia/archive/2008/06/21/54166.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鏍囧噯搴?bitset 綾誨瀷http://www.shnenglu.com/liujiajia/archive/2008/06/06/52400.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Fri, 06 Jun 2008 15:04:00 GMThttp://www.shnenglu.com/liujiajia/archive/2008/06/06/52400.htmlhttp://www.shnenglu.com/liujiajia/comments/52400.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/06/06/52400.html#Feedback0http://www.shnenglu.com/liujiajia/comments/commentRss/52400.htmlhttp://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>

]]>
榪唬鍣?iteratorhttp://www.shnenglu.com/liujiajia/archive/2008/06/06/52399.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Fri, 06 Jun 2008 14:32:00 GMThttp://www.shnenglu.com/liujiajia/archive/2008/06/06/52399.htmlhttp://www.shnenglu.com/liujiajia/comments/52399.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/06/06/52399.html#Feedback3http://www.shnenglu.com/liujiajia/comments/commentRss/52399.htmlhttp://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 GMThttp://www.shnenglu.com/liujiajia/archive/2008/06/02/51928.htmlhttp://www.shnenglu.com/liujiajia/comments/51928.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/06/02/51928.html#Feedback0http://www.shnenglu.com/liujiajia/comments/commentRss/51928.htmlhttp://www.shnenglu.com/liujiajia/services/trackbacks/51928.htmlvector 鏄竴涓被妯℃澘(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++瀛楃澶勭悊 cctypehttp://www.shnenglu.com/liujiajia/archive/2008/06/01/51853.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Sun, 01 Jun 2008 15:45:00 GMThttp://www.shnenglu.com/liujiajia/archive/2008/06/01/51853.htmlhttp://www.shnenglu.com/liujiajia/comments/51853.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/06/01/51853.html#Feedback2http://www.shnenglu.com/liujiajia/comments/commentRss/51853.htmlhttp://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 GMThttp://www.shnenglu.com/liujiajia/archive/2008/06/01/51849.htmlhttp://www.shnenglu.com/liujiajia/comments/51849.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/06/01/51849.html#Feedback0http://www.shnenglu.com/liujiajia/comments/commentRss/51849.htmlhttp://www.shnenglu.com/liujiajia/services/trackbacks/51849.htmlstring瀵硅薄鐨勬搷浣滐細

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;
    }

鍒樺姞鍔?/a> 2008-06-01 23:22 鍙戣〃璇勮
]]>
瀛楃涓茬殑璇誨彇 cin 鍜?getline()http://www.shnenglu.com/liujiajia/archive/2008/06/01/51716.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Sat, 31 May 2008 16:02:00 GMThttp://www.shnenglu.com/liujiajia/archive/2008/06/01/51716.htmlhttp://www.shnenglu.com/liujiajia/comments/51716.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/06/01/51716.html#Feedback1http://www.shnenglu.com/liujiajia/comments/commentRss/51716.htmlhttp://www.shnenglu.com/liujiajia/services/trackbacks/51716.htmlcin
    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><link>http://www.shnenglu.com/liujiajia/archive/2008/05/31/51714.html</link><dc:creator>鍒樺姞鍔?/dc:creator><author>鍒樺姞鍔?/author><pubDate>Sat, 31 May 2008 15:48:00 GMT</pubDate><guid>http://www.shnenglu.com/liujiajia/archive/2008/05/31/51714.html</guid><wfw:comment>http://www.shnenglu.com/liujiajia/comments/51714.html</wfw:comment><comments>http://www.shnenglu.com/liujiajia/archive/2008/05/31/51714.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/liujiajia/comments/commentRss/51714.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/liujiajia/services/trackbacks/51714.html</trackback:ping><description><![CDATA[C++鍒濆鍖栧瓧絎︿覆鐨勬柟寮忓緢鐏墊椿錛?br> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br>#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000"> std;<br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main(</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">)<br>{<br>    </span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000"> s1;              </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">鍒濆鍖栦負絀哄瓧絎︿覆 </span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000"> s2(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">hello</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);     </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">鍒濆鍖栦負涓涓瓧絎︿覆瀛楅潰鍓湰 </span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000"> s3(s2);          </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">灝唖3鍒濆鍖栦負涓涓猻2鐨勫壇鏈?nbsp;</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000"> s4</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">hi jiajia</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;  </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">鍒濆鍖栦負涓涓瓧絎︿覆瀛楅潰鍓湰 </span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000"> s5(</span><span style="COLOR: #000000">15</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">A</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">);<br>    cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">s1</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">s2</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">s3</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">s4</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">s5</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br>    system(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">pause</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>}</span></div> <br>娉ㄦ剰錛氱敱浜庡巻鍙插師鍥犱互鍙婁負浜嗕笌C璇█鍏煎錛屽瓧絎︿覆瀛楅潰鍊間笌鏍囧噯搴搒tring綾誨瀷涓嶆槸鍚屼竴縐嶇被鍨嬨? <img src ="http://www.shnenglu.com/liujiajia/aggbug/51714.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/liujiajia/" target="_blank">鍒樺姞鍔?/a> 2008-05-31 23:48 <a href="http://www.shnenglu.com/liujiajia/archive/2008/05/31/51714.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍛藉悕絀洪棿鐨剈sing澹版槑http://www.shnenglu.com/liujiajia/archive/2008/05/31/51713.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Sat, 31 May 2008 15:36:00 GMThttp://www.shnenglu.com/liujiajia/archive/2008/05/31/51713.htmlhttp://www.shnenglu.com/liujiajia/comments/51713.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/05/31/51713.html#Feedback0http://www.shnenglu.com/liujiajia/comments/commentRss/51713.htmlhttp://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 GMThttp://www.shnenglu.com/liujiajia/archive/2008/05/31/51710.htmlhttp://www.shnenglu.com/liujiajia/comments/51710.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/05/31/51710.html#Feedback0http://www.shnenglu.com/liujiajia/comments/commentRss/51710.htmlhttp://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 GMThttp://www.shnenglu.com/liujiajia/archive/2008/05/31/51655.htmlhttp://www.shnenglu.com/liujiajia/comments/51655.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/05/31/51655.html#Feedback0http://www.shnenglu.com/liujiajia/comments/commentRss/51655.htmlhttp://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><link>http://www.shnenglu.com/liujiajia/archive/2008/05/30/51654.html</link><dc:creator>鍒樺姞鍔?/dc:creator><author>鍒樺姞鍔?/author><pubDate>Fri, 30 May 2008 15:57:00 GMT</pubDate><guid>http://www.shnenglu.com/liujiajia/archive/2008/05/30/51654.html</guid><wfw:comment>http://www.shnenglu.com/liujiajia/comments/51654.html</wfw:comment><comments>http://www.shnenglu.com/liujiajia/archive/2008/05/30/51654.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/liujiajia/comments/commentRss/51654.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/liujiajia/services/trackbacks/51654.html</trackback:ping><description><![CDATA[涓嬮潰浠g爜婕旂ず浜嗙▼搴忓驚鐜粠鐢ㄦ埛杈撳叆璇誨彇瀛楃涓詫紝騫跺瓨鍏ヤ復鏃剁殑瀛楃涓叉暟緇勶紝鐒跺悗灝嗕復鏃跺瓧絎︿覆澶嶅埗鍒皅words鏁扮粍閲岄潰銆?br><br> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">stdio.h</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br>#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">.h</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000"> SIZE 40</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000"> LIM 5</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main(</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">)<br>{<br>    </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> qwords[LIM][SIZE];<br>    </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> temp[SIZE];<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>    <br>    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">LIM </span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> gets(temp))<br>    {<br>        <strong>strcpy</strong>(qwords[i],temp);<br>        i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br>    }<br>    puts(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">The list</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">LIM;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>    {<br>        puts(qwords[i]);<br>    }<br>    <br>    getchar();<br>    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>}</span></div> <img src ="http://www.shnenglu.com/liujiajia/aggbug/51654.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/liujiajia/" target="_blank">鍒樺姞鍔?/a> 2008-05-30 23:57 <a href="http://www.shnenglu.com/liujiajia/archive/2008/05/30/51654.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>strcmp() 姣旇緝瀛楃涓茬殑鍐呭http://www.shnenglu.com/liujiajia/archive/2008/05/30/51653.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Fri, 30 May 2008 15:48:00 GMThttp://www.shnenglu.com/liujiajia/archive/2008/05/30/51653.htmlhttp://www.shnenglu.com/liujiajia/comments/51653.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/05/30/51653.html#Feedback0http://www.shnenglu.com/liujiajia/comments/commentRss/51653.htmlhttp://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 GMThttp://www.shnenglu.com/liujiajia/archive/2008/05/27/51323.htmlhttp://www.shnenglu.com/liujiajia/comments/51323.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/05/27/51323.html#Feedback1http://www.shnenglu.com/liujiajia/comments/commentRss/51323.htmlhttp://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><link>http://www.shnenglu.com/liujiajia/archive/2008/05/27/51321.html</link><dc:creator>鍒樺姞鍔?/dc:creator><author>鍒樺姞鍔?/author><pubDate>Tue, 27 May 2008 11:32:00 GMT</pubDate><guid>http://www.shnenglu.com/liujiajia/archive/2008/05/27/51321.html</guid><wfw:comment>http://www.shnenglu.com/liujiajia/comments/51321.html</wfw:comment><comments>http://www.shnenglu.com/liujiajia/archive/2008/05/27/51321.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.shnenglu.com/liujiajia/comments/commentRss/51321.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/liujiajia/services/trackbacks/51321.html</trackback:ping><description><![CDATA[鍑芥暟鍘熷瀷錛歴ize_t strlen(const char*)<br>浣滅敤錛氳繑鍥炲弬鏁頒腑瀛楃涓茬殑闀垮害銆?br><br>浠ヤ笅浠g爜鏄竴涓埅鍙栧瓧絎︿覆鐨勪緥瀛愶細<br> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">stdio.h</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br>#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">.h</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> fit(</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">,</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">);<br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main(</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">)<br>{<br>    </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> msg[]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Hello moto</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>    <br>    puts(msg);<br>    fit(msg,</span><span style="COLOR: #000000">5</span><span style="COLOR: #000000">);<br>    puts(msg);<br>    puts(msg</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">6</span><span style="COLOR: #000000">);<br>    getchar();<br>    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>}<br></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> fit(</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">,</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> size)<br>{<br>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(strlen(</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">)</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">size)<br>    {<br>        </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">size)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">\0</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">;<br>    }<br>}<br></span></div> 鎴彇鍓嶏細<br> <table style="WIDTH: 320px; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=3 border=1> <tbody> <tr> <td>H</td> <td>e</td> <td>l</td> <td>l</td> <td>o</td> <td>space</td> <td>m</td> <td>o</td> <td>t</td> <td>o</td> <td>\0</td> </tr> </tbody> </table> 鎴彇鍚?br> <table style="WIDTH: 320px; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=3 border=1> <tbody> <tr> <td>H</td> <td>e</td> <td>l</td> <td>l</td> <td>o</td> <td>\0       </td> <td>m</td> <td>o</td> <td>t</td> <td>o</td> <td>\0</td> </tr> </tbody> </table> <br>fit()鏄埅鍙栧瓧絎︿覆鐨勬柟娉曘傚鏋滃瓧絎︿覆鐨勯暱搴﹀ぇ浜庤鎴彇鐨勯暱搴︼紝閭d箞灝嗘寚鍚戣瀛楃涓茬殑鎸囬拡鍚戝悗縐誨姩size浣嶅悗錛屽皢鎸囬拡鎸囧悜鐨勫唴瀹圭疆涓?\0'錛屽嵆瀛楃涓茬粨鏉熴備絾string+size+1澶勪粛鐒跺瓨鍦ㄤ竴涓瓧絎︿覆銆? <img src ="http://www.shnenglu.com/liujiajia/aggbug/51321.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/liujiajia/" target="_blank">鍒樺姞鍔?/a> 2008-05-27 19:32 <a href="http://www.shnenglu.com/liujiajia/archive/2008/05/27/51321.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>瀛楃涓茬殑杈撳叆鍜岃緭鍑猴紙璁よ瘑gets()fgets()scanf()鍜宲uts()fputs()printf()錛?/title><link>http://www.shnenglu.com/liujiajia/archive/2008/05/27/51304.html</link><dc:creator>鍒樺姞鍔?/dc:creator><author>鍒樺姞鍔?/author><pubDate>Tue, 27 May 2008 10:03:00 GMT</pubDate><guid>http://www.shnenglu.com/liujiajia/archive/2008/05/27/51304.html</guid><wfw:comment>http://www.shnenglu.com/liujiajia/comments/51304.html</wfw:comment><comments>http://www.shnenglu.com/liujiajia/archive/2008/05/27/51304.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.shnenglu.com/liujiajia/comments/commentRss/51304.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/liujiajia/services/trackbacks/51304.html</trackback:ping><description><![CDATA[<span style="FONT-SIZE: 18pt"><strong>瀛楃涓茶緭鍏ワ細</strong></span><br><strong><em>gets()</em></strong><br>    char name[20];<br>    printf("Hi,What's your name?\n");<br>    gets(name);<br>    printf("Nice name %s",name);<br>瀹冧嬌鐢ㄤ竴涓湴鍧鎶婂瓧絎︿覆璧嬩簣name銆?br><br>    char name[20];<br>    char *p;<br>    printf("\nEn,What's your name?\n");<br>    p=gets(name);<br>    printf("%s?Oh,Nice name %s\n",name,p);<br>get()鐨勪唬鐮佷嬌鐢╮eturn 鍏抽敭瀛楄繑鍥炲瓧絎︿覆鐨勫湴鍧錛岀▼搴忔妸榪欎釜鍦板潃鍒嗛厤緇欐寚閽坧銆?br><br><em><strong>fgets()</strong></em><br>fgets()鏄負鏂囦歡I/O鑰岃璁$殑錛屽鐞嗛敭鐩樿緭鍏ヤ笉鏄壒鍒柟渚褲?br><br>    printf("\nHi,What's your name?\n");<br>    p=fgets(name,20,stdin);<br>    printf("%s?Oh,Nice name %s\n",name,p);<br>*fgets()鐨勭浜屼釜鍙傛暟璇存槑鏈澶ц鍏ョ殑瀛楃鏁般傚鏋滆繖涓弬鏁板間負n錛岄偅涔坒gets()灝變細璇誨彇鏈澶歯-1涓瓧絎︽垨璇誨畬涓涓崲琛岀涓烘銆備袱涓潯浠舵弧瓚充換鎰忎竴涓粨鏉熴?br>*fgets()璇誨彇鍒版崲琛岀錛屽氨浼氭妸瀹冨瓨鍒板瓧絎︿覆閲岋紝鑰屼笉鏄兂gets()閭f牱涓㈠純瀹冦?br>*fgets()鐨勭涓変釜鍙傛暟璇存槑璇誨摢涓枃浠躲備粠閿洏涓婅鏁版嵁鏃訛紝鍙互浣跨敤stdin(浠h〃standard input)浣滀負鍙傛暟銆?br><br><strong><em>scanf()</em></strong><br>    char name1[11], name2[11];<br>    int count;<br>    printf("\nPlease write down 2 names...\n");<br>    count=scanf("%5s %6s",name1,name2);<br>    printf("\nname1:%s\nname2:%s",name1,name2);<br><br>scanf()鍏佽鎸囧畾杈撳叆瀛楃涓查暱搴︾瓑鏍煎紡銆備笂闈㈢殑紼嬪簭濡傛灉杈撳叆"liujiajia liujiajia",紼嬪簭灝嗚緭鍑?name1:liuji   name2:liujia";<br><br><span style="FONT-SIZE: 18pt"><strong>瀛楃涓茶緭鍑猴細</strong></span><br><em><strong>puts()</strong></em><br>    char str[15]="hello world";<br>    const char *str2="HELLO WORLD";<br>    <br>    puts(str);<br>    puts(str2);<br>    puts(&str[5]);<br>    puts(str2+2);<br>puts()鏄劇ず瀛楃涓叉椂鑷姩鍦ㄥ叾鍚庢坊鍔犱竴涓崲琛岀銆?br>puts(&str[5]);灝嗚緭鍑轟粠str鐨勭鍏釜鍏冪礌寮濮嬪埌瀛楃涓茬粨鏉熴?br>puts(str2+2);灝嗚緭鍑轟粠str2鐨勫湴鍧鍚戝悗縐誨姩涓や釜瀛楃寮濮嬪埌瀛楃涓茬粨鏉熴?br><br><strong><em>fputs()</em></strong><br>    fputs(str,stdout);<br>    fputs(str2,stdout);<br>    fputs(&str[5],stdout);<br>    fputs(str2+2,stdout);<br>*fputs()絎簩涓弬鏁拌〃紺鴻鍐欑殑鏂囦歡銆傚彲浠ヤ嬌鐢╯tdout(浠h〃standard output)浣滀負鍙傛暟銆?br>*fputs()涓嶈嚜鍔ㄨ緭鍑烘崲琛岀錛岃繖涓巔uts()涓嶅お鐩稿悓銆?br><br><strong><em>printf()</em></strong><br>榪欎釜涓嶇敤澶氳浜嗐? <img src ="http://www.shnenglu.com/liujiajia/aggbug/51304.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/liujiajia/" target="_blank">鍒樺姞鍔?/a> 2008-05-27 18:03 <a href="http://www.shnenglu.com/liujiajia/archive/2008/05/27/51304.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍒濇璁よ瘑鏁扮粍銆佹寚閽堝拰瀛楃涓插叧緋?/title><link>http://www.shnenglu.com/liujiajia/archive/2008/05/24/50913.html</link><dc:creator>鍒樺姞鍔?/dc:creator><author>鍒樺姞鍔?/author><pubDate>Fri, 23 May 2008 16:27:00 GMT</pubDate><guid>http://www.shnenglu.com/liujiajia/archive/2008/05/24/50913.html</guid><wfw:comment>http://www.shnenglu.com/liujiajia/comments/50913.html</wfw:comment><comments>http://www.shnenglu.com/liujiajia/archive/2008/05/24/50913.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/liujiajia/comments/commentRss/50913.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/liujiajia/services/trackbacks/50913.html</trackback:ping><description><![CDATA[<p><strong><span style="FONT-SIZE: 18pt">瀛楃涓叉暟緇勫垵濮嬪寲錛?/span><br>(1)char arr[10]="HI";</strong><br>鍒濆鍖栧瓧絎︿覆鏁扮粍鏃訛紝緙栬瘧鍣ㄨ嚜鍔ㄥ皢瀛楃涓叉渶鍚庝竴涓瓧絎﹀悗闈㈠姞涓?\0',浠ヨ〃紺哄瓧絎︿覆鐨勭粨鏉熴?br>濡傛灉鏁扮粍鐨勫ぇ灝忓ぇ浜庡瓧絎︿覆鐨勯暱搴?1錛岄偅涔堟妸瀛楃涓茬粨鏉熷悗闈㈢殑鍏冪礌涔熼兘鍒濆鍖栦負'\0'; <br>鐪嬭繖孌電▼搴忥細<br>瀹氫箟涓涓ぇ灝忎負12鐨勫瓧絎︿覆鏁扮粍<br>char str1[12]="jiajia";        <br>璁╀竴涓猚har鍨嬬殑鎸囬拡鎸囧悜榪欎釜鏁扮粍<br>    char *p1=str1;<br>杈撳嚭榪欎釜瀛楃涓?br>    printf("%s\n\n",str1);<br>鍒╃敤鎸囬拡杈撳嚭榪欎釜瀛楃涓叉暟緇勪腑姣忎釜鍏冪礌鐨勫瓧絎︺佸瓧絎scii鍊箋佸瓧絎﹀瓨鍌ㄥ湴鍧<br>    for(int i=0;i<12;i++)<br>    {<br>        printf("%c:%d:%p\n",*p1,*p1,p1);<br>        p1++;<br>    }<br>鍙互鐪嬪嚭錛屾暟緇勫厓绱犵殑鍚庡嚑浣嶉兘琚垵濮嬪寲鎴愪簡'\0';浣跨敤printf鎵撳嵃瀛楃涓叉暟緇勬椂錛岀▼搴忛亣鍒扮涓涓?\0'灝辯粨鏉熷瀛楃涓茬殑璇誨彇銆?br><br>濡傛灉鏁扮粍鐨勫ぇ灝忓皬浜庡瓧絎︿覆鐨勯暱搴?1錛岀▼搴忓湪榪愯鏃跺彲鑳借鍑虹幇闂錛屾墍浠ュ簲褰撶‘淇濇暟緇勭殑澶у皬瑕佸ぇ浜庡瓧絎︿覆闀垮害鐨勫ぇ灝?1錛?br><br>榪欐紼嬪簭鐨勫瓧絎︿覆闀垮害+1灝忎簬鏁扮粍鐨勫ぇ灝忥細<br>char str2[12]="hello jiajia";<br>    char *p2=str2;</p> <p>    printf("\n\n\n%s\n\n",str2);<br>    <br>    for(int i=0;i<28;i++)<br>    {<br>        printf("%c:%d:%p\n",*p2,*p2,p2);<br>        p2++;<br>    }<br><br>浣跨敤printf鎵撳嵃瀛楃涓詫紝紼嬪簭闇瑕佹壘鍒?\0'鎵嶈兘緇撴潫璇誨彇錛岀粨鏋滄壘閬嶆暣涓暟緇勬病鏈夋壘鍒幫紝鍙湁緇х畫欏虹潃鍦板潃瀵繪壘錛屼竴鐩存壘鍒版煇涓湴鍧涓婄殑assii鏄?鐨勶紝瀛楃涓叉墠璇誨彇瀹屾瘯銆傛墍浠ユ湰孌電▼搴忓湪璇誨彇瀹?hello jiajia"涔嬪悗錛屽悗闈㈠彲鑳借繕浼氭湁鍑犱釜闅忔満鐨勫瓧絎︼紝灝辨槸鍥犱負瀛楃涓茬粓姝簬'\0'銆?br><br><strong>(2)char arr[]="Hello World!";</strong><br>榪欑鍒濆鍖栨柟娉曚笉鐢ㄦ媴蹇冩暟緇勫ぇ灝忚繃灝忕殑鎯呭喌錛屾暟緇勭殑澶у皬鐢辯紪璇戝櫒鍐沖畾銆?br><strong>(3)char arr[]={'H','e','e','l','o',' ','W','o','r','l','d','\0'};</strong><br>鍚岀浜岀鏂規硶緇撴灉鐩稿悓錛屼絾鏄劇劧瑕侀夯鐑﹁澶氥傚彟澶栵紝' '浠h〃絀烘牸錛宎scii鍊兼槸32錛?\0'浠h〃瀛楃涓茬粨鏉燂紝ascii鍊兼槸0錛?br><strong>(4)char *p="Hello World";</strong><br>浣跨敤鏁扮粍鐨勬柟寮忓垵濮嬪寲銆傚悓鏁扮粍涓嶅悓涔嬪鍦ㄤ簬,p鏄竴涓彉閲忥紝鍙互鍋氶掑銆侀掑噺榪愮畻錛岃宎rr鏄暟緇勭殑棣栧湴鍧錛屾槸涓涓湴鍧甯擱噺錛屼笉鑳藉仛閫掑銆侀掑噺榪愮畻銆?br><br>char *name="liujiajia";<br>    name[0]='L';<br>    printf("\n%s\n",name);<br>name[0]='L';榪欏彞浠g爜鍦ㄦ渶鏂扮殑c99鏍囧噯涓細寮曞彂紼嬪簭寮傚父銆傞渶瑕佹敞鎰忋?br><br><br>char *string="c programe";<br>    char *string2;    <br>    string2=string;    //灝嗘寚閽坰tring鐨勫艱祴緇檚tring2<br>    <br>    printf("\nstring=%s,&string=%p,string=%p\n",string,&string,string);<br>    printf("\nstring=%s,&string=%p,string=%p\n",string2,&string2,string2);<br><br>涓婇潰榪欐紼嬪簭鏈鍚庢樉紺猴紝鎸囬拡string鎵鎸囧悜鐨勫湴鍧鍜屾寚閽坰tring2鎵鎸囧悜鐨勫湴鍧鐩稿悓錛岃繖灝辮鏄庡畠浠寚鍚戠殑鏄唴瀛橀噷闈㈠悓涓涓瓧絎︿覆錛屼篃灝辨槸璇村瓧絎︿覆鏈韓騫舵病鏈夊鍒訛紝鑰屾槸浜х敓浜嗕竴涓寚鍚戝悓涓涓瓧絎︿覆鐨勬寚閽堛傝繖鏍風▼搴忕殑鏁堢巼浼氭洿鍔犵殑楂樸傚鏋滈渶瑕佸鍒跺瓧絎︿覆鍙互浣跨敤 strcpy() 鎴?strncpy()銆?br><br></p> <img src ="http://www.shnenglu.com/liujiajia/aggbug/50913.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/liujiajia/" target="_blank">鍒樺姞鍔?/a> 2008-05-24 00:27 <a href="http://www.shnenglu.com/liujiajia/archive/2008/05/24/50913.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍑芥暟鍜屼簩緇存暟緇勭殑鏂拌璇?鍙傛暟鎸囧畾鏁扮粍絎簩緇村拰絎竴緇村ぇ灝?http://www.shnenglu.com/liujiajia/archive/2008/05/20/50581.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Tue, 20 May 2008 14:31:00 GMThttp://www.shnenglu.com/liujiajia/archive/2008/05/20/50581.htmlhttp://www.shnenglu.com/liujiajia/comments/50581.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/05/20/50581.html#Feedback0http://www.shnenglu.com/liujiajia/comments/commentRss/50581.htmlhttp://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><link>http://www.shnenglu.com/liujiajia/archive/2008/05/19/50446.html</link><dc:creator>鍒樺姞鍔?/dc:creator><author>鍒樺姞鍔?/author><pubDate>Mon, 19 May 2008 15:03:00 GMT</pubDate><guid>http://www.shnenglu.com/liujiajia/archive/2008/05/19/50446.html</guid><wfw:comment>http://www.shnenglu.com/liujiajia/comments/50446.html</wfw:comment><comments>http://www.shnenglu.com/liujiajia/archive/2008/05/19/50446.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/liujiajia/comments/commentRss/50446.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/liujiajia/services/trackbacks/50446.html</trackback:ping><description><![CDATA[闃呰涓嬮潰浠g爜錛岀▼搴忓垪涓句簡3縐嶄簩緇存暟緇勪綔涓哄弬鏁頒紶閫掔殑鏂規硶錛?br> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">stdio.h</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000"> ROWS 3</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000"> COLS 4</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> sum_rows(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> arr[][COLS],</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> rows);<br></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> sum_cols(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> [][COLS],</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">);        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">鍙互鐪佺暐鍚嶇О</span><span style="COLOR: #008000"><br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> sum2d(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> (</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">arr)[COLS],</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> rows);   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">鍙︿竴縐嶈娉曞艦寮?/span><span style="COLOR: #008000"><br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main(</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">)<br>{<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> junk[ROWS][COLS]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">{{</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">4</span><span style="COLOR: #000000">},{</span><span style="COLOR: #000000">5</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">6</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">7</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">8</span><span style="COLOR: #000000">},{</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">10</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">11</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">12</span><span style="COLOR: #000000">}};<br>    <br>    sum_rows(junk,ROWS);</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">姹傚嚭姣忚鐨勬暟鍊兼誨拰銆?nbsp;</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);       </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">姹傚嚭姣忓垪鐨勬暟鍊兼誨拰銆?nbsp;</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    sum_cols(junk,ROWS);</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">姹傚嚭鍏ㄩ儴鏁板肩殑鎬誨拰銆?nbsp;</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    <br>    printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">\nthe sum of the junk is %d</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,sum2d(junk,ROWS));<br>    <br>    getchar();<br>    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>} <br></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> sum_rows(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> arr[][COLS],</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> rows)<br>{<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> r,c,tot;<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(r</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;r</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">rows;r</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>    {<br>        tot</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(c</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;c</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">COLS;c</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>        {<br>            tot</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">arr[r][c];<br>        }<br>        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">row%d,sum=%d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,r,tot);<br>    }<br>}<br></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> sum_cols(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> arr[][COLS],</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> rows)<br>{<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> r,c,tot;<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(c</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;c</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">COLS;c</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>    {<br>        tot</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(r</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;r</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">rows;r</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>        {<br>            tot</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">arr[r][c];<br>        }<br>        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">col%d,sum=%d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,c,tot);<br>    }<br>}<br><br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> sum2d(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> (</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">arr)[COLS],</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> rows)<br>{<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> r,c,tot</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(r</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;r</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">rows;r</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>    {<br>        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(c</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;c</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">COLS;c</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>        {<br>            tot</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">arr[r][c];<br>        }<br>    }<br>    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> tot;<br>}<br></span></div> <img src ="http://www.shnenglu.com/liujiajia/aggbug/50446.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/liujiajia/" target="_blank">鍒樺姞鍔?/a> 2008-05-19 23:03 <a href="http://www.shnenglu.com/liujiajia/archive/2008/05/19/50446.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎸囬拡鍜屽緇存暟緇?/title><link>http://www.shnenglu.com/liujiajia/archive/2008/05/19/50440.html</link><dc:creator>鍒樺姞鍔?/dc:creator><author>鍒樺姞鍔?/author><pubDate>Mon, 19 May 2008 14:28:00 GMT</pubDate><guid>http://www.shnenglu.com/liujiajia/archive/2008/05/19/50440.html</guid><wfw:comment>http://www.shnenglu.com/liujiajia/comments/50440.html</wfw:comment><comments>http://www.shnenglu.com/liujiajia/archive/2008/05/19/50440.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/liujiajia/comments/commentRss/50440.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/liujiajia/services/trackbacks/50440.html</trackback:ping><description><![CDATA[<strong>涓銆佸緇存暟緇勫湴鍧鍜屾寚閽堢殑鍏崇郴</strong><br>int arr2[4][2]={{1,2},{3,4},{5,6},{7,8}};<br>printf("arr2=%p,&arr2[0]=%p,arr2[0]=%p,&ar2r[0][0]=%p\n",arr2,&arr2[0],arr2[0],&arr2[0][0]);<br><br> <table style="WIDTH: 364px; BORDER-COLLAPSE: collapse; HEIGHT: 91px" cellSpacing=0 cellPadding=3 border=1> <tbody> <tr> <td style="BACKGROUND-COLOR: #ccffcc">arr[0][0] (1)</td> <td>arr[1][0] (3)</td> <td>arr[2][0] (5)</td> <td>arr[3][0] (7)</td> </tr> <tr> <td style="BACKGROUND-COLOR: #ccffcc">arr[0][1] (2)</td> <td>arr[1][1] (4)</td> <td>arr[2][1] (6)</td> <td>arr[3][1] (8)</td> </tr> </tbody> </table> <br><br>涓婇潰鐨勭▼搴忕殑緇撴灉杈撳嚭绔熺劧閮戒竴鏍楓備負浠涔堝憿錛?br>棣栧厛 arr2 浠h〃鐨勬槸arr2鏁扮粍鐨勯鍦板潃錛屾墍浠?arr2鐨勫煎拰 arr2絎竴涓瓙鍏冪礌arr2[0]鐨勫湴鍧鐩稿悓錛屽嵆 &arr2[0]錛?br>arr2[0]鏄惈鏈変袱涓暣褰㈠厓绱犱竴緇存暟緇勭殑棣栧湴鍧錛屽嵆&arr2[0][0]鐨勫箋?br>綆鍗曠殑璇達細arr[0]鏄竴涓暣鏁板ぇ灝忓璞$殑鍦板潃錛宎rr2鏄袱涓暣鏁板ぇ灝忓璞$殑鍦板潃銆傚洜涓烘暣鏁板拰涓や釜鏁存暟緇勬垚鐨勬暟緇勫紑濮嬩簬鍚屼竴涓湴鍧錛屾墍浠?arr2 鍜?arr2[0] 鍏鋒湁鐩稿悓鐨勬暟鍊箋?br><br><strong>浜屻佹寚閽堬紙鍦板潃錛夎繍綆楀拰澶氱淮鏁扮粍鐨勫叧緋?/strong><br>printf("arr2+1=%p,arr2[0]+1=%p\n",arr2+1,arr2[0]+1);<br>鐜板湪鎴戜滑鐭ラ亾錛宎rr2 鍜?arr2[0]鍏鋒湁鐩稿悓鐨勬暟鍊鹼紝浣嗘槸arr2+1鍜宎rr2[0]+1涓轟粈涔堟暟鍊間笉涓鏍峰憿錛熻繖鏄洜涓猴紝arr2鎸囧悜鐨勫璞″ぇ灝忔槸涓や釜int錛屽効arr2[0]鎵鎸囧悜鐨勫ぇ灝忔槸涓涓猧nt銆傛墍浠rr2+1鐨勫艱姣攁rr2[0]+1鐨勫煎涓涓猧nt澶у皬銆?br><br><strong>涓夈佷嬌鐢?瀵瑰緇存暟緇勫彇鍊?/strong><br>鍥犱負 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><br>瀛﹀畬榪欎釜鐭ヨ瘑鐐癸紝鎵嶅彂鐜板湪鎸囬拡紜疄寰堥毦鎳傘?br> <img src ="http://www.shnenglu.com/liujiajia/aggbug/50440.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/liujiajia/" target="_blank">鍒樺姞鍔?/a> 2008-05-19 22:28 <a href="http://www.shnenglu.com/liujiajia/archive/2008/05/19/50440.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎸囬拡鐨勫熀鏈繍綆?/title><link>http://www.shnenglu.com/liujiajia/archive/2008/05/19/50421.html</link><dc:creator>鍒樺姞鍔?/dc:creator><author>鍒樺姞鍔?/author><pubDate>Mon, 19 May 2008 11:08:00 GMT</pubDate><guid>http://www.shnenglu.com/liujiajia/archive/2008/05/19/50421.html</guid><wfw:comment>http://www.shnenglu.com/liujiajia/comments/50421.html</wfw:comment><comments>http://www.shnenglu.com/liujiajia/archive/2008/05/19/50421.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/liujiajia/comments/commentRss/50421.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/liujiajia/services/trackbacks/50421.html</trackback:ping><description><![CDATA[<p>瀵規寚閽堝彲浠ヨ繘琛?strong>璧嬪?/strong>銆?strong>姹傚?/strong>鎴?strong>鍙栧?/strong>銆?strong>鍙栨寚閽堢殑鍦板潃</strong>銆?strong>灝嗕竴涓寚閽堝姞涓婁竴涓暣鏁?/strong>銆?strong>澧炲姞鎸囬拡鐨勫?/strong>銆?strong>姹傚樊鍊?/strong>鐨勬搷浣溿傝鍙傜湅浠ヤ笅浠g爜灞曠ず浜嗗嚑縐嶆儏褰細<br></p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">stdio.h</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main(</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">)<br>{<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> urn[</span><span style="COLOR: #000000">5</span><span style="COLOR: #000000">]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">{</span><span style="COLOR: #000000">100</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">200</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">300</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">400</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">500</span><span style="COLOR: #000000">};<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">p1,</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">p2,</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">p3;<br>    <br>    p1</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">urn;         </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">鎶婁竴涓湴鍧璧嬬粰鎸囬拡 </span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    p2</span><span style="COLOR: #000000">=&</span><span style="COLOR: #000000">urn[</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">];     </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">鍙栧緱urn[2]鐨勫湴鍧錛屽茍璧嬬粰涓涓寚閽?/span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    <br>    printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">鏁扮粍鍚勪釜鍏冪礌鐨勫煎拰鍦板潃錛歕n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">); <br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">5</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>    {<br>        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">urn[%d]=%d   &urn[%d]=%p;\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,i,urn[i],i,</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">urn[i]);<br>    }<br>    <br>    printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">\n鎸囬拡鎸囧悜鐨勫湴鍧,鎸囬拡鎸囧悜鍦板潃鐨勫?鎸囬拡鐨勫湴鍧\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>    printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">p1=%p    ,*p1=%d         ,&p1=%p</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,p1,</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">p1,</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">p1); <br><br>    printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">\n鎸囬拡鍔犱笂鏁存暟鐨勬晥鏋?鎸囬拡+int!=鎸囬拡錛屾寚閽?int==鍦板潃)錛歕n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>    printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">p1+4=%p,*(p1+4)=%d</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,p1</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">4</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">(p1</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">4</span><span style="COLOR: #000000">));<br>    <br>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">printf("&(p1+4)=%p",&(p1+4))</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">error:p1+4鏄竴涓湴鍧錛屼笉鑳藉鍏惰繘琛屽彇鍦板潃鎿嶄綔錛屼絾鍙互灝唒1+4璧嬬粰涓涓寚閽?nbsp;</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    <br>    p1</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">p++==p1+1銆俻1+1鏄竴涓湴鍧錛屽皢p1+1璧嬬粰p1</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">\n鍦╬1++浠ュ悗錛歕np1=%p    ,*p1=%d         ,&p1=%p\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,p1,</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">p1,</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">p1);<br>    <br>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">姹備袱涓寚閽堝樊鍊?nbsp;</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">\np2=%p,p1=%p,p2-p1=%d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,p2,p1,p2</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">p1); <br>    <br>    getchar();<br>    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>}</span></div> <img src ="http://www.shnenglu.com/liujiajia/aggbug/50421.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/liujiajia/" target="_blank">鍒樺姞鍔?/a> 2008-05-19 19:08 <a href="http://www.shnenglu.com/liujiajia/archive/2008/05/19/50421.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>甯︽湁鏁扮粍綾誨瀷鍙傛暟鐨勫嚱鏁?/title><link>http://www.shnenglu.com/liujiajia/archive/2008/05/16/50110.html</link><dc:creator>鍒樺姞鍔?/dc:creator><author>鍒樺姞鍔?/author><pubDate>Fri, 16 May 2008 15:54:00 GMT</pubDate><guid>http://www.shnenglu.com/liujiajia/archive/2008/05/16/50110.html</guid><wfw:comment>http://www.shnenglu.com/liujiajia/comments/50110.html</wfw:comment><comments>http://www.shnenglu.com/liujiajia/archive/2008/05/16/50110.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/liujiajia/comments/commentRss/50110.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/liujiajia/services/trackbacks/50110.html</trackback:ping><description><![CDATA[<p>浼犻掓暟緇勫弬鏁幫紝鍏舵牳蹇冨氨鏄紶閫掕鏁扮粍鐨勯鍦板潃銆傜劧鍚庡嚱鏁板啀閫氳繃鏁扮粍銆佹寚閽堢瓑錛岀敤璇ユ暟緇勭殑棣栧湴鍧鏋勯犱竴涓柊鐨勬暟緇勬垨鎸囬拡錛屽啀閫氳繃浼犻掕繃鏉ョ殑鏁扮粍澶у皬錛屽璇ユ暟緇勮繘琛屾搷浣溿?/p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">#include </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">stdio.h</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000"> SIZE 4</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> sumbyarr(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> a[],</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> n);<br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> sumbypointer(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">p,</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> n);<br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> sumbyaddress(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> address,</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> n);<br>int sumbypointer2(int *begin,int *end)<br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main(</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">)<br>{<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> arr[SIZE]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">{</span><span style="COLOR: #000000">10</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">20</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">30</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">40</span><span style="COLOR: #000000">};<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> sum1;<br>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">浣跨敤鏁扮粍浣滀負褰㈠弬鎺ユ敹鏁扮粍 </span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    sum1</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">sumbyarr(arr,SIZE);<br>    printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">the total of the arr by array is:%d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,sum1);<br>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">浣跨敤鎸囬拡浣滀負褰㈠弬鎺ユ敹鏁扮粍 </span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> sum2;<br>    sum2</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">sumbypointer(arr,SIZE);<br>    printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">the total of the arr by pointer is:%d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,sum2);<br>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">浣跨敤鍦板潃浣滀負褰㈠弬鎺ユ敹鏁扮粍 </span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> sum3;<br>    sum3</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">sumbyaddress(arr,SIZE);<br>    printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">the total of the arr by address is:%d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,sum3);<br>       <br>    //浣跨敤涓や釜鎸囬拡褰㈠弬鎺ユ敹<br>    int sum4;<br>    sum4=sumbypointer2(arr,arr+SIZE);<br>    printf(<span style="COLOR: #000000">"</span><span style="COLOR: #000000">the total of the arr by pointer2 is:%d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,sum4);<br></span><br><br>    getchar();<br>    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>} <br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> sumbyarr(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> a[],</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> n)<br>{ <br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> index;<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> total</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(index</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;index</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">n;index</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>    {<br>        total</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">a[index];<br>    }<br>    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> total;<br>}<br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> sumbypointer(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">p,</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> n)<br>{<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> index;<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> total</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(index</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;index</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">n;index</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">,p</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>    {<br>        total</span><span style="COLOR: #000000">+=*</span><span style="COLOR: #000000">p;<br>    }<br>    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> total;<br>}<br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> sumbyaddress(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> address,</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> n)<br>{<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">p</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">address;<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> index;<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> total</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(index</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;index</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">n;index</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">,p</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>    {<br>        total</span><span style="COLOR: #000000">+=*</span><span style="COLOR: #000000">p;<br>    }<br>    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> total;<br>}<br>int sumbypointer2(int *begin,int *end)<br>{<br>    int total=0;<br>    while(begin<end)<br>    {<br>        total+=*begin;<br>        begin++;<br>    }<br>    return total;<br>}</span></div> <br>浠ヤ笂浠g爜婕旂ず鎬庢牱瀹氫箟鏈夋暟緇勪綔涓哄弬鏁扮殑鍑芥暟銆?br>濡傛灉鏁扮粍浣滀負鍙傛暟浼犻掕繘鍏ユ煇涓嚱鏁幫紝騫朵笖鍦ㄨ繖涓嚱鏁頒腑鏀瑰彉浜嗘暟緇勫厓绱犵殑鍊鹼紝閭d箞紼嬪簭榪斿洖鍚庯紝榪欎釜鏁扮粍鍏冪礌鐨勫兼湁娌℃湁鏀瑰彉鍛紵<br><br>褰撶劧錛屽兼敼鍙樹簡錛屽洜涓烘暟緇勬槸閫氳繃鍦板潃浼犻掔殑錛屾敼鍙樹簡琚皟鍑芥暟涓暟緇勭殑鍊間篃灝辨剰鍛崇潃鍚屾椂鏀瑰彉浜嗕富璋冨嚱鏁頒腑鏁扮粍鐨勫箋傚洜涓哄畠浠殑鍦板潃鏄浉鍚岀殑銆? <img src ="http://www.shnenglu.com/liujiajia/aggbug/50110.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/liujiajia/" target="_blank">鍒樺姞鍔?/a> 2008-05-16 23:54 <a href="http://www.shnenglu.com/liujiajia/archive/2008/05/16/50110.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>璁よ瘑鏁扮粍鍜屾寚閽堢殑鍏崇郴http://www.shnenglu.com/liujiajia/archive/2008/05/16/50097.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Fri, 16 May 2008 13:30:00 GMThttp://www.shnenglu.com/liujiajia/archive/2008/05/16/50097.htmlhttp://www.shnenglu.com/liujiajia/comments/50097.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/05/16/50097.html#Feedback0http://www.shnenglu.com/liujiajia/comments/commentRss/50097.htmlhttp://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><link>http://www.shnenglu.com/liujiajia/archive/2008/05/16/49998.html</link><dc:creator>鍒樺姞鍔?/dc:creator><author>鍒樺姞鍔?/author><pubDate>Thu, 15 May 2008 16:06:00 GMT</pubDate><guid>http://www.shnenglu.com/liujiajia/archive/2008/05/16/49998.html</guid><wfw:comment>http://www.shnenglu.com/liujiajia/comments/49998.html</wfw:comment><comments>http://www.shnenglu.com/liujiajia/archive/2008/05/16/49998.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/liujiajia/comments/commentRss/49998.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/liujiajia/services/trackbacks/49998.html</trackback:ping><description><![CDATA[<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">stdio.h</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000"> PLAYER 4</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000"> MATCH 3</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main(</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">)<br>{<br>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">灝?鍚嶇悆鍛樿繎涓夊満姣旇禌鐨勫緱鍒嗗垵濮嬪寲</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> arrmark[MATCH][PLAYER]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">{<br>        {</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">8</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">7</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">5</span><span style="COLOR: #000000">},<br>        {</span><span style="COLOR: #000000">8</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">10</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">8</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">7</span><span style="COLOR: #000000">},<br>        {</span><span style="COLOR: #000000">7</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">7</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">10</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">6</span><span style="COLOR: #000000">}<br>        }; <br>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">杈撳嚭鍏蜂綋鎴愮嘩</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i,j;<br>    printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">***********Roony  Ronaldo  Kaka  Grosso\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">MATCH;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>    {<br>        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">match%d:</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,i);<br>        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(j</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;j</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">PLAYER;j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>        {<br>            printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%8d</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,arrmark[i][j]);<br>        }<br>        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>    }<br>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">鎵撳嵃鎬誨垎</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> temp</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>    printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">total        </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">PLAYER;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">姹傛瘡涓悆鍛樼殑鎬誨垎 </span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    {<br>        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(j</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;j</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">MATCH;j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>        {<br>            temp</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">arrmark[j][i];<br>        }<br>        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%d      </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,temp);<br>        temp</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>    } <br>    getchar();<br>} </span></div> <img src ="http://www.shnenglu.com/liujiajia/aggbug/49998.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/liujiajia/" target="_blank">鍒樺姞鍔?/a> 2008-05-16 00:06 <a href="http://www.shnenglu.com/liujiajia/archive/2008/05/16/49998.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎸囧畾鏁扮粍澶у皬http://www.shnenglu.com/liujiajia/archive/2008/05/15/49996.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Thu, 15 May 2008 15:32:00 GMThttp://www.shnenglu.com/liujiajia/archive/2008/05/15/49996.htmlhttp://www.shnenglu.com/liujiajia/comments/49996.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/05/15/49996.html#Feedback0http://www.shnenglu.com/liujiajia/comments/commentRss/49996.htmlhttp://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><link>http://www.shnenglu.com/liujiajia/archive/2008/05/15/49994.html</link><dc:creator>鍒樺姞鍔?/dc:creator><author>鍒樺姞鍔?/author><pubDate>Thu, 15 May 2008 15:11:00 GMT</pubDate><guid>http://www.shnenglu.com/liujiajia/archive/2008/05/15/49994.html</guid><wfw:comment>http://www.shnenglu.com/liujiajia/comments/49994.html</wfw:comment><comments>http://www.shnenglu.com/liujiajia/archive/2008/05/15/49994.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/liujiajia/comments/commentRss/49994.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/liujiajia/services/trackbacks/49994.html</trackback:ping><description><![CDATA[浠ヤ笅浠g爜灞曠ず鏁扮粍鍒濆鍖栫殑鍚勭鎯呭喌錛?br> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">stdio.h</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000"> SIZE 4</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main(</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">)<br>{<br>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">涓鑸垵濮嬪寲 </span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> arr[SIZE]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">{</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">4</span><span style="COLOR: #000000">};<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> index;<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(index</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;index</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">SIZE;index</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>    {<br>        arr[index]</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br>        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">arr[%d]=%d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,index,arr[index]);<br>    }<br>    <br>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">瀹氫箟騫跺垵濮嬪寲涓涓猚onst鏁扮粍銆傛暟緇勫唴鍏冪礌涓嶈兘淇敼 </span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> arr2[SIZE]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">{</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">4</span><span style="COLOR: #000000">};<br>    <br>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">鏁扮粍涓嶅垵濮嬪寲錛屽厓绱犵殑鍊間負闅忔満鏁般?nbsp;</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> arr3[SIZE];  <br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(index</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;index</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">SIZE;index</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>    {<br>        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">arr3[%d]=%d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,index,arr3[index]);<br>    }<br><br>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">濡傛灉鍒濆鍖栨暟緇勪腑閮ㄥ垎鍏冪礌錛屽叾浠栧厓绱犲垯琚垵濮嬪寲涓? </span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> arr4[SIZE]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">{</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">}; <br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(index</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;index</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">SIZE;index</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>    {<br>        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">arr4[%d]=%d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,index,arr4[index]);<br>    }<br>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">鎸囧畾瑕佸垵濮嬪寲鐨勫厓绱?/span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> arr5[SIZE]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">{</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,[</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">,[</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">4</span><span style="COLOR: #000000">};<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(index</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;index</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">SIZE;index</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>    {<br>        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">arr5[%d]=%d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,index,arr5[index]);<br>    }<br>    <br>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">鏁扮粍鐨勫厓绱犱釜鏁頒笉鍥哄畾 </span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> arr6[]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">{</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">4</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">5</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">6</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">7</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">8</span><span style="COLOR: #000000">};<br>    printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">sizeof arr6=%d,sizeof arr6[0]=%d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000"> arr6,</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000"> arr6[</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">]);<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(index</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;index</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000"> arr6</span><span style="COLOR: #000000">/</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000"> arr6[</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">];index</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>    {<br>        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">arr6[%d]=%d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,index,arr6[index]);<br>    }<br>    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>}</span></div> <br>紼嬪簭榪愯緇撴灉鏄細<br><img height=426 alt="" src="http://www.shnenglu.com/images/cppblog_com/liujiajia/arrinit.jpg" width=284 border=0><br>鎬庝箞鏍鳳紵鏁扮粍鐨勫垵濮嬪寲鏂瑰紡澶氱澶氭牱銆備絾瑕佺伒媧昏繍鐢ㄣ? <img src ="http://www.shnenglu.com/liujiajia/aggbug/49994.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/liujiajia/" target="_blank">鍒樺姞鍔?/a> 2008-05-15 23:11 <a href="http://www.shnenglu.com/liujiajia/archive/2008/05/15/49994.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>璁よ瘑sizeofhttp://www.shnenglu.com/liujiajia/archive/2008/05/15/49942.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Thu, 15 May 2008 08:01:00 GMThttp://www.shnenglu.com/liujiajia/archive/2008/05/15/49942.htmlhttp://www.shnenglu.com/liujiajia/comments/49942.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/05/15/49942.html#Feedback0http://www.shnenglu.com/liujiajia/comments/commentRss/49942.htmlhttp://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

]]>
浣跨敤igooglehttp://www.shnenglu.com/liujiajia/archive/2008/05/15/49882.html鍒樺姞鍔?/dc:creator>鍒樺姞鍔?/author>Wed, 14 May 2008 16:00:00 GMThttp://www.shnenglu.com/liujiajia/archive/2008/05/15/49882.htmlhttp://www.shnenglu.com/liujiajia/comments/49882.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/05/15/49882.html#Feedback0http://www.shnenglu.com/liujiajia/comments/commentRss/49882.htmlhttp://www.shnenglu.com/liujiajia/services/trackbacks/49882.htmligoogle 銆傚彲浠ヨ嚜宸辨坊鍔爂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 GMThttp://www.shnenglu.com/liujiajia/archive/2008/05/14/49769.htmlhttp://www.shnenglu.com/liujiajia/comments/49769.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/05/14/49769.html#Feedback0http://www.shnenglu.com/liujiajia/comments/commentRss/49769.htmlhttp://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 GMThttp://www.shnenglu.com/liujiajia/archive/2008/05/09/49367.htmlhttp://www.shnenglu.com/liujiajia/comments/49367.htmlhttp://www.shnenglu.com/liujiajia/archive/2008/05/09/49367.html#Feedback2http://www.shnenglu.com/liujiajia/comments/commentRss/49367.htmlhttp://www.shnenglu.com/liujiajia/services/trackbacks/49367.htmlch=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久久| 国产精品久久久久久久久久免费|