锘??xml version="1.0" encoding="utf-8" standalone="yes"?>在线精品视频免费观看,中文国产亚洲喷潮,欧美三级午夜理伦三级中文幕 http://www.shnenglu.com/idc/c++鎶鏈氦嫻?/description>zh-cnSat, 29 Nov 2025 17:06:11 GMTSat, 29 Nov 2025 17:06:11 GMT60C璇█鏂囦歡榪藉姞鍙傛暟鎿嶄綔 http://www.shnenglu.com/idc/archive/2012/06/03/177374.html涓鍙惰崏涓鍙惰崏Sun, 03 Jun 2012 15:55:00 GMThttp://www.shnenglu.com/idc/archive/2012/06/03/177374.htmlhttp://www.shnenglu.com/idc/comments/177374.htmlhttp://www.shnenglu.com/idc/archive/2012/06/03/177374.html#Feedback0http://www.shnenglu.com/idc/comments/commentRss/177374.htmlhttp://www.shnenglu.com/idc/services/trackbacks/177374.html   
    鏂囦歡鐨勬墦寮錛坒open鍑芥暟錛?br />   
    fopen鍑芥暟鐢ㄦ潵鎵撳紑涓涓枃浠訛紝鍏惰皟鐢ㄧ殑涓鑸艦寮忎負(fù)錛氭枃浠舵寚閽堝悕=fopen錛堟枃浠跺悕錛屼嬌鐢ㄦ枃浠舵柟寮忥級(jí)錛?鍏朵腑錛?鏂囦歡鎸囬拡鍚?蹇呴』鏄璇存槑涓篎ILE 綾誨瀷鐨勬寚閽堝彉閲忥紱"鏂囦歡鍚?鏄鎵撳紑鏂囦歡鐨勬枃浠跺悕錛?浣跨敤鏂囦歡鏂瑰紡"鏄寚鏂囦歡鐨勭被鍨嬪拰鎿嶄綔瑕佹眰銆?"鏂囦歡鍚?鏄瓧絎︿覆甯擱噺鎴栧瓧絎︿覆鏁扮粍銆?br />   
    鐩稿叧鍑芥暟 :open,fclose
   
    琛ㄥご鏂囦歡 :#include<stdio.h>
   
    瀹氫箟鍑芥暟 :FILE * fopen錛坈onst char * path,const char * mode錛夛紱
   
    鍑芥暟璇存槑
   
    鍙傛暟path瀛楃涓插寘鍚鎵撳紑鐨勬枃浠惰礬寰勫強(qiáng)鏂囦歡鍚嶏紝鍙傛暟mode瀛楃涓插垯浠h〃鐫嫻佸艦鎬併?br />   
    mode鏈変笅鍒楀嚑縐嶅艦鎬佸瓧絎︿覆錛?br />   
    r 鎵撳紑鍙鏂囦歡錛岃鏂囦歡蹇呴』瀛樺湪銆?br />   
    r+ 鎵撳紑鍙鍐欑殑鏂囦歡錛岃鏂囦歡蹇呴』瀛樺湪銆?br />   
    w 鎵撳紑鍙啓鏂囦歡錛岃嫢鏂囦歡瀛樺湪鍒欐枃浠墮暱搴︽竻涓?,鍗寵鏂囦歡鍐呭浼?xì)娑堝け銆傝嫢鏂囦歡涓嶅瓨鍦ㄥ垯寤虹珛璇ユ枃浠躲?br />   
    w+ 鎵撳紑鍙鍐欐枃浠訛紝鑻ユ枃浠跺瓨鍦ㄥ垯鏂囦歡闀垮害娓呬負(fù)闆訛紝鍗寵鏂囦歡鍐呭浼?xì)娑堝け銆傝嫢鏂囦歡涓嶅瓨鍦ㄥ垯寤虹珛璇ユ枃浠躲?br />   
    a 浠ラ檮鍔犵殑鏂瑰紡鎵撳紑鍙啓鏂囦歡銆傝嫢鏂囦歡涓嶅瓨鍦紝鍒欎細(xì)寤虹珛璇ユ枃浠訛紝濡傛灉鏂囦歡瀛樺湪錛屽啓鍏ョ殑鏁版嵁浼?xì)琚姞鍒版枃錃g灝撅紝鍗蟲枃浠跺師鍏堢殑鍐呭浼?xì)琚繚鐣欍?br />   
    a+ 浠ラ檮鍔犳柟寮忔墦寮鍙鍐欑殑鏂囦歡銆傝嫢鏂囦歡涓嶅瓨鍦紝鍒欎細(xì)寤虹珛璇ユ枃浠訛紝濡傛灉鏂囦歡瀛樺湪錛屽啓鍏ョ殑鏁版嵁浼?xì)琚姞鍒版枃錃g灝懼悗錛屽嵆鏂囦歡鍘熷厛鐨勫唴瀹逛細(xì)琚繚鐣欍?br />   
    涓婅堪鐨勫艦鎬佸瓧絎︿覆閮藉彲浠ュ啀鍔犱竴涓猙瀛楃錛屽rb銆亀+b鎴朼b+絳夌粍鍚堬紝鍔犲叆b 瀛楃鐢ㄦ潵鍛婅瘔鍑芥暟搴撴墦寮鐨勬枃浠朵負(fù)浜岃繘鍒舵枃浠訛紝鑰岄潪綰枃瀛楁枃浠躲備笉榪囧湪POSIX緋葷粺錛屽寘鍚獿inux閮戒細(xì)蹇界暐璇ュ瓧絎︺傜敱fopen錛堬級(jí)鎵寤虹珛鐨勬柊鏂囦歡浼?xì)鍏锋湁S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH錛?666錛夋潈闄愶紝姝ゆ枃浠舵潈闄愪篃浼?xì)鍙傝僽mask 鍊箋?br />   
    榪斿洖鍊?br />   
    鏂囦歡欏哄埄鎵撳紑鍚庯紝鎸囧悜璇ユ祦鐨勬枃浠舵寚閽堝氨浼?xì)琚珮q斿洖銆傝嫢鏋滄枃浠舵墦寮澶辮觸鍒欒繑鍥濶ULL,騫舵妸閿欒浠g爜瀛樺湪errno 涓?br />   
    闄勫姞璇存槑
   
    涓鑸岃█錛屽紑鏂囦歡鍚庝細(xì)浣滀竴浜涙枃浠惰鍙栨垨鍐欏叆鐨勫姩浣滐紝鑻ュ紑鏂囦歡澶辮觸錛屾帴涓嬫潵鐨勮鍐欏姩浣滀篃鏃犳硶欏哄埄榪涜錛屾墍浠ュ湪fopen錛堬級(jí)鍚庤浣滈敊璇垽鏂強(qiáng)澶勭悊銆?br />   
    鑼冧緥
   
    #include<stdio.h>
   
    main錛堬級(jí)
   
    {
   
    FILE * fp;
   
    fp=fopen錛?noexist","a+"錛夛紱
   
    if錛坒p= =NULL錛?return;
   
    fclose錛坒p錛夛紱
   
    }

]]>
鏁欎綘浼樺寲C璇█紼嬪簭 http://www.shnenglu.com/idc/archive/2012/05/26/176283.html涓鍙惰崏涓鍙惰崏Sat, 26 May 2012 14:15:00 GMThttp://www.shnenglu.com/idc/archive/2012/05/26/176283.htmlhttp://www.shnenglu.com/idc/comments/176283.htmlhttp://www.shnenglu.com/idc/archive/2012/05/26/176283.html#Feedback1http://www.shnenglu.com/idc/comments/commentRss/176283.htmlhttp://www.shnenglu.com/idc/services/trackbacks/176283.html   
    涓銆佺▼搴忕粨鏋勭殑浼樺寲
   
    1銆佽〃杈懼紡
   
    瀵逛簬涓涓〃杈懼紡涓悇縐嶈繍綆楁墽琛岀殑浼樺厛欏哄簭涓嶅お鏄庣‘鎴栧鏄撴販娣嗙殑鍦版柟錛屽簲褰撻噰鐢ㄥ渾鎷彿鏄庣‘鎸囧畾瀹冧滑鐨勪紭鍏堥『搴忋備竴涓〃杈懼紡閫氬父涓嶈兘鍐欏緱澶鏉傦紝濡傛灉琛ㄨ揪寮忓お澶嶆潅錛屾椂闂翠箙浜?jiǎn)浠ュ悗锛岃嚜宸变篃涓嶅?guī)槗鐪嬪緱鎳傦紝涓嶅埄浜庝互鍚庣殑緇存姢銆?br />   
    2銆佺▼搴忕殑涔﹀啓緇撴瀯
   
    铏界劧涔﹀啓鏍煎紡騫朵笉浼?xì)濯?jiǎng)鍝嶇敓鎴愮殑浠g爜璐ㄩ噺錛屼絾鏄湪瀹為檯緙栧啓紼嬪簭鏃惰繕鏄簲璇ュ皧寰竴瀹氱殑涔﹀啓瑙勫垯錛屼竴涓功鍐欐竻鏅般佹槑浜?jiǎn)鐨劷E嬪簭錛屾湁鍒╀簬浠ュ悗鐨勭淮鎶ゃ傚湪涔﹀啓紼嬪簭鏃訛紝鐗瑰埆鏄浜嶹hile銆乫or銆乨o…while銆乮f…elst銆乻witch…case絳夎鍙ユ垨榪欎簺璇彞宓屽緇勫悎鏃訛紝搴旈噰鐢?緙╂牸"鐨勪功鍐欏艦寮忥紝
   
    3銆佸噺灝戝垽鏂鍙?br />   
    鑳藉浣跨敤鏉′歡緙栬瘧錛坕fdef錛夌殑鍦版柟灝變嬌鐢ㄦ潯浠剁紪璇戣屼笉浣跨敤if璇彞錛屾湁鍒╀簬鍑忓皯緙栬瘧鐢熸垚鐨勪唬鐮佺殑闀垮害錛岃兘澶熶笉鐢ㄥ垽鏂鍙ュ垯灝戠敤鍒ゆ柇鐢ㄨ鍙ャ?br />   
    4銆佹爣璇嗙
   
    紼嬪簭涓嬌鐢ㄧ殑鐢ㄦ埛鏍囪瘑絎﹂櫎瑕侀伒寰爣璇嗙鐨勫懡鍚嶈鍒欎互澶栵紝涓鑸笉瑕佺敤浠f暟絎﹀彿錛堝a銆乥銆亁1銆亂1錛変綔涓哄彉閲忓悕錛屽簲閫夊彇鍏鋒湁鐩稿叧鍚箟鐨勮嫳鏂囧崟璇嶏紙鎴栫緝鍐欙級(jí)鎴栨眽璇嫾闊充綔涓烘爣璇嗙錛屼互澧炲姞紼嬪簭鐨勫彲璇繪э紝濡傦細(xì)count銆乶umber1銆乺ed銆亀ork絳夈?br />   
    5銆佸畾涔夊父鏁?br />   
    鍦ㄧ▼搴忓寲璁捐榪囩▼涓紝瀵逛簬緇忓父浣跨敤鐨勪竴浜涘父鏁幫紝濡傛灉灝嗗畠鐩存帴鍐欏埌紼嬪簭涓幓錛屼竴鏃﹀父鏁扮殑鏁板煎彂鐢熷彉鍖栵紝灝卞繀欏婚愪釜鎵懼嚭紼嬪簭涓墍鏈夌殑甯告暟錛屽茍閫愪竴榪涜淇敼錛岃繖鏍峰繀鐒朵細(xì)闄嶄綆紼嬪簭鐨勫彲緇存姢鎬с傚洜姝わ紝搴斿敖閲忓綋閲囩敤棰勫鐞嗗懡浠ゆ柟寮忔潵瀹氫箟甯告暟錛岃屼笖榪樺彲浠ラ伩鍏嶈緭鍏ラ敊璇?br />   
    浜屻佷唬鐮佺殑浼樺寲
   
    1銆佷嬌鐢ㄨ嚜鍔犮佽嚜鍑忔寚浠?br />   
    閫氬父浣跨敤鑷姞銆佽嚜鍑忔寚浠ゅ拰澶嶅悎璧嬪艱〃杈懼紡錛堝a-=1鍙?qiáng)a+=1絳夛級(jí)閮借兘澶熺敓鎴愰珮璐ㄩ噺鐨勭▼搴忎唬鐮侊紝緙栬瘧鍣ㄩ氬父閮借兘澶熺敓鎴恑nc鍜宒ec涔嬬被鐨勬寚浠わ紝鑰屼嬌鐢╝=a+1鎴朼=a-1涔嬬被鐨勬寚浠わ紝鏈夊緢澶欳緙栬瘧鍣ㄩ兘浼?xì)鐢熸垚浜屽堫C笁涓瓧鑺傜殑鎸囦護(hù)銆傚湪AVR鍗曠墖閫傜敤鐨処CCAVR銆丟CCAVR銆両AR絳塁緙栬瘧鍣ㄤ互涓婂嚑縐嶄功鍐欐柟寮忕敓鎴愮殑浠g爜鏄竴鏍風(fēng)殑錛屼篃鑳藉鐢熸垚楂樿川閲忕殑inc鍜宒ec涔嬬被鐨勭殑浠g爜銆?br />   
    2銆佹煡琛?br />   
    鍦ㄧ▼搴忎腑涓鑸笉榪涜闈炲父澶嶆潅鐨勮繍綆楋紝濡傛誕鐐規(guī)暟鐨勪箻闄ゅ強(qiáng)寮鏂圭瓑錛屼互鍙?qiáng)涓浜涘鏉傜殑鏁板妯″瀷鐨勬彃琛ヨ繍綆楋紝瀵硅繖浜涘嵆娑堣楁椂闂村張娑堣垂璧勬簮鐨勮繍綆楋紝搴斿敖閲忎嬌鐢ㄦ煡琛ㄧ殑鏂瑰紡錛屽茍涓斿皢鏁版嵁琛ㄧ疆浜庣▼搴忓瓨鍌ㄥ尯銆傚鏋滅洿鎺ョ敓鎴愭墍闇鐨勮〃姣旇緝鍥伴毦錛屼篃灝介噺鍦ㄥ惎鍔ㄦ椂鍏堣綆楋紝鐒跺悗鍦ㄦ暟鎹瓨鍌ㄥ櫒涓敓鎴愭墍闇鐨勮〃錛屽悗浠ュ湪紼嬪簭榪愯鐩存帴鏌ヨ〃灝卞彲浠ヤ簡(jiǎn)錛屽噺灝戜簡(jiǎn)紼嬪簭鎵ц榪囩▼涓噸澶嶈綆楃殑宸ヤ綔閲忋?br />   
    3銆佷嬌鐢ㄥ敖閲忓皬鐨勬暟鎹被鍨?br />   
    鑳藉浣跨敤瀛楃鍨嬶紙char錛夊畾涔夌殑鍙橀噺錛屽氨涓嶈浣跨敤鏁村瀷錛坕nt錛夊彉閲忔潵瀹氫箟錛涜兘澶熶嬌鐢ㄦ暣鍨嬪彉閲忓畾涔夌殑鍙橀噺灝變笉瑕佺敤闀挎暣鍨嬶紙long int錛夛紝鑳戒笉浣跨敤嫻偣鍨嬶紙float錛夊彉閲忓氨涓嶈浣跨敤嫻偣鍨嬪彉閲忋傚綋鐒?dòng)灱屽湪瀹氫箟鍙橀噺鍚庝笉瑕伃憛杩囧彉閲忕殑浣滅敤鑼冨涍_(dá)紝濡傛灉瓚呰繃鍙橀噺鐨勮寖鍥磋祴鍊鹼紝C緙栬瘧鍣ㄥ茍涓嶆姤閿欙紝浣嗙▼搴忚繍琛岀粨鏋滃嵈閿欎簡(jiǎn)錛岃屼笖榪欐牱鐨勯敊璇緢闅懼彂鐜般傚湪ICCAVR涓紝鍙互鍦∣ptions涓瀹氫嬌鐢╬rintf鍙傛暟錛屽敖閲忎嬌鐢ㄥ熀鏈瀷鍙傛暟錛?c銆?d銆?x銆?X銆?u鍜?s鏍煎紡璇存槑絎︼級(jí)錛屽皯鐢ㄩ暱鏁村瀷鍙傛暟錛?ld銆?lu銆?lx鍜?lX鏍煎紡璇存槑絎︼級(jí)錛岃嚦浜庢誕鐐瑰瀷鐨勫弬鏁幫紙%f錛夊垯灝介噺涓嶈浣跨敤錛屽叾瀹僀緙栬瘧鍣ㄤ篃涓鏍楓傚湪鍏跺畠鏉′歡涓嶅彉鐨勬儏鍐典笅錛屼嬌鐢?f鍙傛暟錛屼細(xì)浣跨敓鎴愮殑浠g爜鐨勬暟閲忓鍔犲緢澶氾紝鎵ц閫熷害闄嶄綆銆?br />   
    4銆侀夋嫨鍚堥傜殑綆楁硶鍜屾暟鎹粨鏋?br />   
    搴旇鐔熸?zhèn)壗帡娉曡瑷錛岀煡閬撳悇縐嶇畻娉曠殑浼樼己鐐癸紝鍏蜂綋璧勬枡璇峰弬瑙佺浉搴旂殑鍙傝冭祫鏂欙紝鏈夊緢澶氳綆楁満涔︾睄涓婇兘鏈変粙緇嶃傚皢姣旇緝鎱㈢殑欏哄簭鏌ユ壘娉曠敤杈冨揩鐨勪簩鍒嗘煡鎵炬垨涔卞簭鏌ユ壘娉曚唬鏇匡紝鎻掑叆鎺掑簭鎴栧啋娉℃帓搴忔硶鐢ㄥ揩閫熸帓搴忋佸悎騫舵帓搴忔垨鏍規(guī)帓搴忎唬鏇匡紝閮藉彲浠ュぇ澶ф彁楂樼▼搴忔墽琛岀殑鏁堢巼閫夋嫨涓縐嶅悎閫傜殑鏁版嵁緇撴瀯涔熷緢閲嶈錛屾瘮濡備綘鍦ㄤ竴鍫嗛殢鏈哄瓨鏀劇殑鏁頒腑浣跨敤浜?jiǎn)澶ч噺鐨勬彃鍏ュ拰鍒犻櫎鎸囦护锛岄偅鋴社敤閾捐〃瑕佸揩寰楀銆傛暟緇勪笌鎸囬拡璇彞鍏鋒湁鍗佸垎瀵嗙爜鐨勫叧緋伙紝涓鑸潵璇達(dá)紝鎸囬拡姣旇緝鐏墊椿綆媧侊紝鑰屾暟緇勫垯姣旇緝鐩磋錛屽鏄撶悊瑙c傚浜庡ぇ閮ㄥ垎鐨勭紪璇戝櫒錛屼嬌鐢ㄦ寚閽堟瘮浣跨敤鏁扮粍鐢熸垚鐨勪唬鐮佹洿鐭紝鎵ц鏁堢巼鏇撮珮銆備絾鏄湪Keil涓垯鐩稿弽錛屼嬌鐢ㄦ暟緇勬瘮浣跨敤鐨勬寚閽堢敓鎴愮殑浠g爜鏇寸煭銆?img src ="http://www.shnenglu.com/idc/aggbug/176283.html" width = "1" height = "1" />

]]>
c璇█涓璼wap闂灝忕粨 http://www.shnenglu.com/idc/archive/2012/04/08/170439.html涓鍙惰崏涓鍙惰崏Sun, 08 Apr 2012 06:15:00 GMThttp://www.shnenglu.com/idc/archive/2012/04/08/170439.htmlhttp://www.shnenglu.com/idc/comments/170439.htmlhttp://www.shnenglu.com/idc/archive/2012/04/08/170439.html#Feedback0http://www.shnenglu.com/idc/comments/commentRss/170439.htmlhttp://www.shnenglu.com/idc/services/trackbacks/170439.html    #include<stdio.h>

    void swap1錛坕nt x,int y錛?/p>

    {

    int temp;

    temp=x;

    x=y;

    y=temp;

    }

    void swap2錛坕nt *x,int *y錛?/p>

    {

    int *temp;

    temp=x;

    x=y;

    y=temp;

    }

    void swap3錛坕nt *x,int *y錛?/p>

    {

    int temp;

    temp=*x;

    *x=*y;

    *y=temp;

    }

    void swap4錛坕nt a[],int b[]錛?/p>

    {

    int temp;

    temp=a[0];

    a[0]=b[0];

    b[0]=temp;

    }

    void swap5錛坕nt a[],int b[]錛?/p>

    {

    int temp;

    temp=*a;

    *a=*b;

    *b=temp;

    }

    int main錛堬級(jí)

    {

    int x,y;

    x=4;

    y=3;

    swap1錛坸,y錛夛紱

    printf錛?swap1: x:%d,y:%d\n",x,y錛夛紱//褰㈠弬浼犲鹼紝涓嶈兘浜ゆ崲錛屽疄闄呬紶榪囧幓鏄嫹璐濈殑涓浠斤紝娌℃敼鍙樹富鍑芥暟涓瓁,y

    swap2錛?amp;x,&y錛夛紱

    printf錛?swap2: x:%d,y:%d\n",x,y錛夛紱//涓嶈兘浜ゆ崲錛屽嚱鏁頒腑鍙槸鍦板潃浜ゆ崲浜?jiǎn)涓嬪Q屽湴鍧鎸囧悜鐨勫唴瀹規(guī)病鏈変氦鎹?/p>

    swap3錛?amp;x,&y錛夛紱

    printf錛?swap3: x:%d,y:%d\n",x,y錛夛紱//鑳戒氦鎹紝鍦板潃鎸囧悜鐨勫唴瀹硅繘琛屼簡(jiǎn)浜ゆ崲

    swap4錛?amp;x,&y錛夛紱

    printf錛?swap4: x:%d,y:%d\n",x,y錛夛紱//鑳戒氦鎹紝鍦板潃鎸囧悜鐨勫唴瀹硅繘琛屼氦鎹?/p>

    swap5錛?amp;x,&y錛夛紱

    printf錛?swap5: x:%d,y:%d\n",x,y錛夛紱//鑳戒氦鎹紝鍦板潃鎸囧悜鐨勫唴瀹硅繘琛屼氦鎹?/p>

    return 0;

    }

    swap1: x:4,y:3

    swap2: x:4,y:3

    swap3: x:3,y:4

    swap4: x:4,y:3

    swap5: x:3,y:4



]]>
C/C++ 閫氱敤 Makefile http://www.shnenglu.com/idc/archive/2012/03/28/169324.html涓鍙惰崏涓鍙惰崏Wed, 28 Mar 2012 11:17:00 GMThttp://www.shnenglu.com/idc/archive/2012/03/28/169324.htmlhttp://www.shnenglu.com/idc/comments/169324.htmlhttp://www.shnenglu.com/idc/archive/2012/03/28/169324.html#Feedback0http://www.shnenglu.com/idc/comments/commentRss/169324.htmlhttp://www.shnenglu.com/idc/services/trackbacks/169324.htmlC++ 紼嬪簭榪涜緙栬瘧鍜岃繛鎺ヤ互浜х敓鍙墽琛岀▼搴忕殑閫氱敤 Makefile.

銆銆鍦ㄤ嬌鐢?Makefile 涔嬪墠錛屽彧闇瀵瑰畠榪涜涓浜涚畝鍗曠殑璁劇疆鍗沖彲錛涜屼笖涓緇忚緗紝鍗充嬌浠ュ悗瀵規(guī)簮紼嬪簭鏂囦歡鏈夋墍澧炲噺涓鑸篃涓嶅啀闇瑕佹敼鍔?Makefile.鍥犳錛屽嵆渚挎槸涓涓病鏈夊涔?fàn)杩?Makefile 涔﹀啓瑙勫垯鐨勪漢錛屼篃鍙互涓鴻嚜宸辯殑 C/C++ 紼嬪簭蹇熷緩绔嬩竴涓彲宸ヤ綔鐨?Makefile.

銆銆榪欎釜 Makefile 鍙互鍦?GNU Make 鍜?GCC 緙栬瘧鍣ㄤ笅姝e父宸ヤ綔銆備絾鏄笉鑳戒繚璇佸浜庡叾瀹冪増鏈殑 Make 鍜岀紪璇戝櫒涔熻兘姝e父宸ヤ綔銆?/p>

銆銆濡傛灉浣犲彂鐜頒簡(jiǎn)鏈枃涓殑閿欒錛屾垨鑰呭鏈枃鏈変粈涔堟劅鎯蟲垨寤鴻錛屽彲閫氳繃 whyglinux AT hotmail DOT com 閭鍜屼綔鑰呰仈緋匯?/p>

銆銆姝?Makefile 鐨勪嬌鐢ㄦ柟娉曞涓嬶細(xì)[list=1][*]紼嬪簭鐩綍鐨勭粍緇囧敖閲忓皢鑷繁鐨勬簮紼嬪簭闆嗕腑鍦ㄤ竴涓洰褰曚腑錛屽茍涓旀妸 Makefile 鍜屾簮紼嬪簭鏀懼湪涓璧鳳紝榪欐牱鐢ㄨ搗鏉ユ瘮杈冩柟渚褲傚綋鐒?dòng)灱屼篃鍙互灏嗘簮绋嬪簭鍒喚c誨瓨鏀懼湪涓嶅悓鐨勭洰褰曚腑銆?/p>

銆銆鍦ㄧ▼搴忕洰褰曚腑鍒涘緩涓涓悕涓?Makefile 鐨勬枃鏈枃浠訛紝灝嗗悗闈㈠垪鍑虹殑 Makefile 鐨勫唴瀹瑰鍒跺埌榪欎釜鏂囦歡涓傦紙娉ㄦ剰錛氬湪澶嶅埗鐨勮繃紼嬩腑錛孧akfile 涓悇鍛戒護(hù)鍓嶉潰鐨?Tab 瀛楃鏈夊彲鑳借杞崲鎴愯嫢騫蹭釜絀烘牸銆傝繖縐嶆儏鍐典笅闇瑕佹妸 Makefile 鍛戒護(hù)鍓嶉潰鐨勮繖浜涚┖鏍兼浛鎹負(fù)涓涓?Tab.錛?/p>

銆銆灝嗗綋鍓嶅伐浣滅洰褰曞垏鎹㈠埌 Makefile 鎵鍦ㄧ殑鐩綍銆傜洰鍓嶏紝榪欎釜 Makefile 鍙敮鎸佸湪褰撳墠鐩綍涓殑璋冪敤錛屼笉鏀寔褰撳墠鐩綍鍜?Makefile 鎵鍦ㄧ殑璺緞涓嶆槸鍚屼竴鐩綍鐨勬儏鍐點(diǎn)?/p>

銆銆[*]鎸囧畾鍙墽琛屾枃浠剁▼搴忕紪璇戝拰榪炴帴鎴愬姛鍚庝駭鐢熺殑鍙墽琛屾枃浠跺湪 Makefile 涓殑 PROGRAM 鍙橀噺涓瀹氥傝繖涓欏逛笉鑳戒負(fù)絀恒備負(fù)鑷繁紼嬪簭鐨勫彲鎵ц鏂囦歡璧蜂竴涓湁鎰忎箟鐨勫悕瀛愬惂銆?/p>

銆銆[*]鎸囧畾婧愮▼搴忚緙栬瘧鐨勬簮紼嬪簭鐢卞叾鎵鍦ㄧ殑璺緞鍜屾枃浠剁殑鎵╁睍鍚嶄袱欏規(guī)潵紜畾銆傜敱浜庡ご鏂囦歡鏄氳繃鍖呭惈鏉ヤ嬌鐢ㄧ殑錛屾墍浠ュ湪榪欓噷璇寸殑婧愮▼搴忎笉搴斿寘鍚ご鏂囦歡銆?/p>

銆銆紼嬪簭鎵鍦ㄧ殑璺緞鍦?SRCDIRS 涓瀹氥傚鏋滄簮紼嬪簭鍒嗗竷鍦ㄤ笉鍚岀殑鐩綍涓紝閭d箞闇瑕佸湪 SRCDIRS 涓竴涓鎸囧畾錛屽茍涓旇礬寰勫悕涔嬮棿鐢ㄧ┖鏍煎垎闅斻?/p>

銆銆鍦?SRCEXTS 涓寚瀹氱▼搴忎腑浣跨敤鐨勬枃浠剁被鍨嬨侰/C++ 紼嬪簭鐨勬墿灞曞悕涓鑸湁姣旇緝鍥哄畾鐨勫嚑縐嶅艦寮忥細(xì)銆俢銆併侰銆併俢c銆併俢pp銆併侰PP銆併俢++銆併俢p銆佹垨鑰呫俢xx錛堝弬瑙?man gcc錛夈傛墿灞曞悕鍐沖畾浜?jiǎn)绋嬪簭鏄?C 榪樻槸 C++ 紼嬪簭錛氥俢 鏄?C 紼嬪簭錛屽叾瀹冩墿灞曞悕琛ㄧず C++ 紼嬪簭銆備竴鑸浐瀹氫嬌鐢ㄥ叾涓殑涓縐嶆墿灞曞悕鍗沖彲銆備絾鏄篃鏈夊彲鑳介渶瑕佷嬌鐢ㄥ縐嶆墿灞曞悕錛岃繖鍙互鍦?SOURCE_EXT 涓竴涓鎸囧畾錛屽悇涓墿灞曞悕涔嬮棿鐢ㄧ┖鏍煎垎闅斻?/p>

銆銆铏界劧騫朵笉甯哥敤錛屼絾鏄?C 紼嬪簭涔熷彲浠ヨ浣滀負(fù) C++ 紼嬪簭緙栬瘧銆傝繖鍙互閫氳繃鍦?Makefile 涓緗?CC = $錛圕XX錛?鍜?CFLAGS = $錛圕XXFLAGS錛?涓ら」鍗沖彲瀹炵幇銆?/p>

銆銆榪欎釜 Makefile 鏀寔 C銆丆++ 浠ュ強(qiáng) C/C++ 娣峰悎涓夌緙栬瘧鏂瑰紡錛歔list][*]濡傛灉鍙寚瀹?.c 鎵╁睍鍚嶏紝閭d箞榪欐槸涓涓?C 紼嬪簭錛岀敤 $錛圕C錛?琛ㄧず鐨勭紪璇戝懡浠よ繘琛岀紪璇戝拰榪炴帴銆?/p>

銆銆[*]濡傛灉鎸囧畾鐨勬槸闄?.c 涔嬪鐨勫叾瀹冩墿灞曞悕錛堝 .cc銆併俢pp銆併俢xx 絳夛級(jí)錛岄偅涔堣繖鏄竴涓?C++ 紼嬪簭錛岀敤 $錛圕XX錛?榪涜緙栬瘧鍜岃繛鎺ャ?/p>

銆銆[*]濡傛灉鏃㈡寚瀹氫簡(jiǎn) .c錛屽張鎸囧畾浜?jiǎn)鍏跺?C++ 鎵╁睍鍚嶏紝閭d箞榪欐槸 C/C++ 娣峰悎紼嬪簭錛屽皢鐢?$錛圕C錛?緙栬瘧鍏朵腑鐨?C 紼嬪簭錛岀敤 $錛圕XX錛?緙栬瘧鍏朵腑鐨?C++ 紼嬪簭錛屾渶鍚庡啀鐢?$錛圕XX錛?榪炴帴紼嬪簭銆?/p>

銆銆[/list]榪欎簺宸ヤ綔閮芥槸 make 鏍規(guī)嵁鍦?Makefile 涓彁渚涚殑紼嬪簭鏂囦歡綾誨瀷錛堟墿灞曞悕錛夎嚜鍔ㄥ垽鏂繘琛岀殑錛屼笉闇瑕佺敤鎴峰共棰勩?/p>

銆銆[*]鎸囧畾緙栬瘧閫夐」緙栬瘧閫夐」鐢變笁閮ㄥ垎緇勬垚錛氶澶勭悊閫夐」銆佺紪璇戦夐」浠ュ強(qiáng)榪炴帴閫夐」錛屽垎鍒敱 CPPFLAGS銆丆FLAGS涓嶤XXFLAGS銆丩DFLAGS 鎸囧畾銆?/p>

銆銆CPPFLAGS 閫夐」鍙弬鑰?C 棰勫鐞嗗懡浠?cpp 鐨勮鏄庯紝浣嗘槸娉ㄦ剰涓嶈兘鍖呭惈 -M 浠ュ強(qiáng)鍜?-M 鏈夊叧鐨勯夐」銆傚鏋滄槸 C/C++ 娣峰悎緙栫▼錛屼篃鍙互鍦ㄨ繖閲岃緗?C/C++ 鐨勪竴浜涘叡鍚岀殑緙栬瘧閫夐」銆?/p>

銆銆CFLAGS 鍜?CXXFLAGS 涓や釜鍙橀噺閫氬父鐢ㄦ潵鎸囧畾緙栬瘧閫夐」銆傚墠鑰呬粎浠呯敤浜庢寚瀹?C 紼嬪簭鐨勭紪璇戦夐」錛屽悗鑰呬粎浠呯敤浜庢寚瀹?C++ 紼嬪簭鐨勭紪璇戦夐」銆傚叾瀹炰篃鍙互鍦ㄤ袱涓彉閲忎腑鎸囧畾涓浜涢澶勭悊閫夐」錛堝嵆涓浜涙湰鏉ュ簲璇ユ斁鍦?CPPFLAGS 涓殑閫夐」錛夛紝鍜?CPPFLAGS 騫舵病鏈夋槑紜殑鐣岄檺銆?/p>

銆銆榪炴帴閫夐」鍦?LDFLAGS 涓寚瀹氥傚鏋滃彧浣跨敤 C/C++ 鏍囧噯搴擄紝涓鑸病鏈夊繀瑕佽緗傚鏋滀嬌鐢ㄤ簡(jiǎn)闈炴爣鍑嗗簱錛屽簲璇ュ湪榪欓噷鎸囧畾榪炴帴闇瑕佺殑閫夐」錛屽搴撴墍鍦ㄧ殑璺緞銆佸簱鍚嶄互鍙?qiáng)鍏跺畠鑱旀帴閫夐」銆?/p>

銆銆鐜板湪鐨勫簱涓鑸兘鎻愪緵浜?jiǎn)涓涓浉搴旂殑 .pc 鏂囦歡鏉ヨ褰曚嬌鐢ㄥ簱鎵闇瑕佺殑棰勭紪璇戦夐」銆佺紪璇戦夐」鍜岃繛鎺ラ夐」絳変俊鎭紝閫氳繃 pkg-config 鍙互鍔ㄦ佹彁鍙栬繖浜涢夐」銆備笌鐢辯敤鎴鋒樉寮忔寚瀹氬悇涓夐」鐩告瘮錛屼嬌鐢?pkg-config 鏉ヨ闂簱鎻愪緵鐨勯夐」鏇存柟渚褲佹洿鍏烽氱敤鎬с傚湪鍚庨潰鍙互鐪嬪埌涓涓?GTK+ 紼嬪簭鐨勪緥瀛愶紝鍏剁紪璇戝拰榪炴帴閫夐」鐨勬寚瀹氬氨鏄敤 pkg-config 瀹炵幇鐨勩?/p>

銆銆[*]緙栬瘧鍜岃繛鎺ヤ笂闈㈢殑鍚勯」璁劇疆濂戒箣鍚庝繚瀛?Makefile 鏂囦歡銆傛墽琛?make 鍛戒護(hù)錛岀▼搴忓氨寮濮嬬紪璇戜簡(jiǎn)銆?/p>

銆銆鍛戒護(hù) make 浼?xì)鏍规?Makefile 涓緗ソ鐨勮礬寰勫拰鏂囦歡綾誨瀷鎼滅儲(chǔ)婧愮▼搴忔枃浠訛紝鐒跺悗鏍規(guī)嵁鏂囦歡鐨勭被鍨嬭皟鐢ㄧ浉搴旂殑緙栬瘧鍛戒護(hù)銆佷嬌鐢ㄧ浉搴旂殑緙栬瘧閫夐」瀵圭▼搴忚繘琛岀紪璇戙?/p>

銆銆緙栬瘧鎴愬姛涔嬪悗紼嬪簭鐨勮繛鎺ヤ細(xì)鑷姩榪涜銆傚鏋滄病鏈夐敊璇殑璇濇渶緇堜細(xì)浜х敓紼嬪簭鐨勫彲鎵ц鏂囦歡銆?/p>

銆銆娉ㄦ剰錛氬湪瀵圭▼搴忕紪璇戜箣鍚庯紝浼?xì)漶旂敓鍜屾簮绋嬪簭鏂囦欢涓涓瀵瑰簲鐨?.d 鏂囦歡銆傝繖鏄〃紺轟緷璧栧叧緋葷殑鏂囦歡錛岄氳繃瀹冧滑 make 鍐沖畾鍦ㄦ簮紼嬪簭鏂囦歡鍙樺姩涔嬪悗瑕佽繘琛屽摢浜涙洿鏂般備負(fù)姣忎竴涓簮紼嬪簭鏂囦歡寤虹珛鐩稿簲鐨?.d 鏂囦歡榪欎篃鏄?GNU Make 鎺ㄨ崘鐨勬柟寮忋?/p>

銆銆[*]Makefile 鐩爣錛圱argets錛?/p>

銆銆涓嬮潰鏄叧浜庤繖涓?Makefile 鎻愪緵鐨勭洰鏍囦互鍙?qiáng)瀹冩墍瀹屾垚鐨勫姛鑳斤細(xì)[list][*]make緙栬瘧鍜岃繛鎺ョ▼搴忋傜浉褰撲簬 make all. [*]make objs浠呬粎緙栬瘧紼嬪簭浜х敓 .o 鐩爣鏂囦歡錛屼笉榪涜榪炴帴錛堜竴鑸緢灝戝崟鐙嬌鐢級(jí)銆?/p>

銆銆[*]make clean鍒犻櫎緙栬瘧浜х敓鐨勭洰鏍囨枃浠跺拰渚濊禆鏂囦歡銆?/p>

銆銆[*]make cleanall鍒犻櫎鐩爣鏂囦歡銆佷緷璧栨枃浠朵互鍙?qiáng)鍙墽琛屾枃錃g銆?/p>

銆銆[*]make rebuild閲嶆柊緙栬瘧鍜岃繛鎺ョ▼搴忋傜浉褰撲簬 make clean && make all. [/list][/list]鍏充簬榪欎釜 Makefile 鐨勫疄鐜板師鐞嗕笉鍑嗗璇︾粏瑙i噴浜?jiǎn)銆傚鏋滄湁鍏磋叮鐨勮瘽錛屽彲鍙傝冩枃鏈垪鍑虹殑“鍙傝冭祫鏂?#8221;銆?/p>

銆銆Makefile 鐨勫唴瀹瑰涓嬶細(xì)############################################################################### # # Generic Makefile for C/C++ Program # # Author錛?whyglinux 錛坵hyglinux AT hotmail DOT com錛?# Date錛?nbsp;  2006/03/04 # Description錛?# The makefile searches in <SRCDIRS> directories for the source files # with extensions specified in <SOURCE_EXT>錛?then compiles the sources # and finally produces the <PROGRAM>錛?the executable file錛?by linking # the objectives. # Usage錛?#   $ make           compile and link the program. #   $ make objs      compile only 錛坣o linking. Rarely used錛夈?#   $ make clean     clean the objectives and dependencies. #   $ make cleanall  clean the objectives錛?dependencies and executable. #   $ make rebuild   rebuild the program. The same as make clean && make all. #============================================================================== ## Customizing Section錛?adjust the following if necessary. ##============================================================================= # The executable file name. # It must be specified. # PROGRAM   錛? a.out    # the executable name PROGRAM   錛? # The directories in which source files reside. # At least one path should be specified. # SRCDIRS   錛? .        # current directory SRCDIRS   錛? # The source file types 錛坔eaders excluded錛夈?# At least one type should be specified. # The valid suffixes are among of .c錛?.C錛?.cc錛?.cpp錛?.CPP錛?.c++錛?.cp錛?or .cxx. # SRCEXTS   錛? .c      # C program # SRCEXTS   錛? .cpp    # C++ program # SRCEXTS   錛? .c .cpp # C/C++ program SRCEXTS   錛? # The flags used by the cpp 錛坢an cpp for more錛夈?# CPPFLAGS  錛? -Wall -Werror # show all warnings and take them as errors CPPFLAGS  錛? # The compiling flags used only for C. # If it is a C++ program錛?no need to set these flags. # If it is a C and C++ merging program錛?set these flags for the C parts. CFLAGS    錛? CFLAGS    += # The compiling flags used only for C++. # If it is a C program錛?no need to set these flags. # If it is a C and C++ merging program錛?set these flags for the C++ parts. CXXFLAGS  錛? CXXFLAGS  += # The library and the link options 錛?C and C++ common錛夈?LDFLAGS   錛? LDFLAGS   += ## Implict Section錛?change the following only when necessary. ##============================================================================= # The C program compiler. Uncomment it to specify yours explicitly. #CC      = gcc # The C++ program compiler. Uncomment it to specify yours explicitly. #CXX     = g++ # Uncomment the 2 lines to compile C programs as C++ ones. #CC      = $錛圕XX錛?#CFLAGS  = $錛圕XXFLAGS錛?# The command used to delete file. #RM        = rm -f ## Stable Section錛?usually no need to be changed. But you can add more. ##============================================================================= SHELL   = /bin/sh SOURCES = $錛坒oreach d錛?錛圫RCDIRS錛夛紝$錛坵ildcard $錛坅ddprefix $錛坉錛?*錛?錛圫RCEXTS錛夛級(jí)錛夛級(jí) OBJS    = $錛坒oreach x錛?錛圫RCEXTS錛夛紝 \       $錛坧atsubst %$錛坸錛夛紝%.o錛?錛坒ilter %$錛坸錛夛紝$錛圫OURCES錛夛級(jí)錛夛級(jí) DEPS    = $錛坧atsubst %.o錛?.d錛?錛圤BJS錛夛級(jí) .PHONY 錛?all objs clean cleanall rebuild all 錛?$錛圥ROGRAM錛?# Rules for creating the dependency files 錛堛俤錛夈?#—— %.d 錛?%.c @$錛圕C錛?-MM -MD $錛圕FLAGS錛?$< %.d 錛?%.C @$錛圕C錛?-MM -MD $錛圕XXFLAGS錛?$< %.d 錛?%.cc @$錛圕C錛?-MM -MD $錛圕XXFLAGS錛?$< %.d 錛?%.cpp @$錛圕C錛?-MM -MD $錛圕XXFLAGS錛?$< %.d 錛?%.CPP @$錛圕C錛?-MM -MD $錛圕XXFLAGS錛?$< %.d 錛?%.c++ @$錛圕C錛?-MM -MD $錛圕XXFLAGS錛?$< %.d 錛?%.cp @$錛圕C錛?-MM -MD $錛圕XXFLAGS錛?$< %.d 錛?%.cxx @$錛圕C錛?-MM -MD $錛圕XXFLAGS錛?$< # Rules for producing the objects. #—— objs 錛?$錛圤BJS錛?%.o 錛?%.c $錛圕C錛?-c $錛圕PPFLAGS錛?$錛圕FLAGS錛?$< %.o 錛?%.C $錛圕XX錛?-c $錛圕PPFLAGS錛?$錛圕XXFLAGS錛?$< %.o 錛?%.cc $錛圕XX錛?-c $錛圕PPFLAGS錛?$錛圕XXFLAGS錛?$< %.o 錛?%.cpp $錛圕XX錛?-c $錛圕PPFLAGS錛?$錛圕XXFLAGS錛?$< %.o 錛?%.CPP $錛圕XX錛?-c $錛圕PPFLAGS錛?$錛圕XXFLAGS錛?$< %.o 錛?%.c++ $錛圕XX -c $錛圕PPFLAGS錛?$錛圕XXFLAGS錛?$< %.o 錛?%.cp $錛圕XX錛?-c $錛圕PPFLAGS錛?$錛圕XXFLAGS錛?$< %.o 錛?%.cxx $錛圕XX錛?-c $錛圕PPFLAGS錛?$錛圕XXFLAGS錛?$< # Rules for producing the executable. #—— $錛圥ROGRAM錛?錛?$錛圤BJS錛?ifeq 錛?錛坰trip $錛圫RCEXTS錛夛級(jí)錛?.c錛?nbsp; # C file $錛圕C錛?-o $錛圥ROGRAM錛?$錛圤BJS錛?$錛圠DFLAGS錛?else                            # C++ file $錛圕XX錛?-o $錛圥ROGRAM錛?$錛圤BJS錛?$錛圠DFLAGS錛?endif -include $錛圖EPS錛?rebuild錛?clean all clean 錛?@$錛圧M錛?*.o *.d cleanall錛?clean @$錛圧M錛?$錛圥ROGRAM錛?$錛圥ROGRAM錛夈俥xe ### End of the Makefile ##  Suggestions are welcome  ## All rights reserved ### ###############################################################################

銆銆涓嬮潰鎻愪緵涓や釜渚嬪瓙鏉ュ叿浣撹鏄庝笂闈?Makefile 鐨勭敤娉曘?/p>

銆銆[color=darkred]渚嬩竴銆Hello World 紼嬪簭[/color]

銆銆榪欎釜紼嬪簭鐨勫姛鑳芥槸杈撳嚭 Hello錛?world錛?榪欐牱涓琛屾枃瀛椼傜敱 hello.h銆乭ello.c銆乵ain.cxx 涓変釜鏂囦歡緇勬垚銆傚墠涓や釜鏂囦歡鏄?C 紼嬪簭錛屽悗涓涓槸 C++ 紼嬪簭錛屽洜姝よ繖鏄竴涓?C 鍜?C++ 娣風(fēng)紪紼嬪簭銆?/p>

銆銆/* File name錛?hello.h  * C header file  */ #ifndef HELLO_H #define HELLO_H #ifdef __cplusplus extern "C" { #endif   void print_hello錛堬級(jí)錛?#ifdef __cplusplus } #endif #endif

銆銆/* File name錛?hello.c  * C source file.  */ #include "hello.h" #include <stdio.h> void print_hello錛堬級(jí) {   puts錛?"Hello錛?world錛? 錛夛紱 }

銆銆/* File name錛?main.cxx  * C++ source file.  */ #include "hello.h" int main錛堬級(jí) {   print_hello錛堬級(jí)錛?nbsp;  return 0錛?}

銆銆寤虹珛涓涓柊鐨勭洰褰曪紝鐒跺悗鎶婅繖涓変釜鏂囦歡鎷瘋礉鍒扮洰褰曚腑錛屼篃鎶?Makefile 鏂囦歡鎷瘋礉鍒扮洰褰曚腑銆備箣鍚庯紝瀵?Makefile 鐨勭浉鍏抽」鐩繘琛屽涓嬭緗細(xì)PROGRAM   錛? hello      # 璁劇疆榪愯紼嬪簭鍚?SRCDIRS   錛? .          # 婧愮▼搴忎綅浜庡綋鍓嶇洰褰曚笅 SRCEXTS   錛? .c .cxx    # 婧愮▼搴忔枃浠舵湁 .c 鍜?.cxx 涓ょ綾誨瀷 CFLAGS    錛? -g         # 涓?C 鐩爣紼嬪簭鍖呭惈 GDB 鍙敤鐨勮皟璇曚俊鎭?CXXFLAGS  錛? -g         # 涓?C++ 鐩爣紼嬪簭鍖呭惈 GDB 鍙敤鐨勮皟璇曚俊鎭?/p>

銆銆鐢變簬榪欎釜綆鍗曠殑紼嬪簭鍙嬌鐢ㄤ簡(jiǎn) C 鏍囧噯搴撶殑鍑芥暟錛坧uts錛夛紝鎵浠ュ浜?CFLAGS 鍜?CXXFLAGS 娌℃湁榪囧鐨勮姹傦紝LDFLAGS 鍜?CPPFLAGS 閫夐」涔熸棤闇璁劇疆銆?/p>

銆銆緇忚繃涓婇潰鐨勮緗箣鍚庯紝鎵ц make 鍛戒護(hù)灝卞彲浠ョ紪璇戠▼搴忎簡(jiǎn)銆傚鏋滄病鏈夐敊璇嚭鐜扮殑璇濓紝銆?hello  灝卞彲浠ヨ繍琛岀▼搴忎簡(jiǎn)銆?/p>

銆銆濡傛灉淇敼浜?jiǎn)婧惤E嬪簭鐨勮瘽錛屽彲浠ョ湅鍒板彧鏈夊拰淇敼鏈夊叧鐨勬簮鏂囦歡琚紪璇戙備篃鍙互鍐嶄負(fù)紼嬪簭娣誨姞鏂扮殑婧愭枃浠訛紝鍙瀹冧滑鐨勬墿灞曞悕鏄凡緇忓湪 Makefile 涓緗繃鐨勶紝閭d箞灝辨病鏈夊繀瑕佷慨鏀廣Makefile.

銆銆[color=darkred]渚嬩簩銆GTK+ 鐗?Hello World 紼嬪簭[/color]

銆銆榪欎釜 GTK+ 2.0 鐗堢殑 Hello World 紼嬪簭鍙互浠庝笅闈㈢殑緗戝潃涓婂緱鍒幫細(xì)http://www.gtk.org/tutorial/c58.html#SEC-HELLOWORLD.褰撶劧錛岃緙栬瘧 GTK+ 紼嬪簭錛岃繕闇瑕佷綘鐨勭郴緇熶笂宸茬粡瀹夎濂戒簡(jiǎn) GTK+.

銆銆璺熺涓涓緥瀛愪竴鏍鳳紝鍗曠嫭鍒涘緩涓涓柊鐨勭洰褰曪紝鎶婁笂闈㈢綉欏典腑鎻愪緵鐨勭▼搴忎繚瀛樹負(fù) main.c 鏂囦歡銆傚 Makefile 鍋氬涓嬭緗細(xì)PROGRAM   錛? hello      # 璁劇疆榪愯紼嬪簭鍚?SRCDIRS   錛? .          # 婧愮▼搴忎綅浜庡綋鍓嶇洰褰曚笅 SRCEXTS   錛? .c         # 婧愮▼搴忔枃浠跺彧鏈?.c 涓縐嶇被鍨?CFLAGS    錛? `pkg-config ——cflags gtk+-2.0`  # CFLAGS LDFLAGS   錛? `pkg-config ——libs gtk+-2.0`    # LDFLAGS

銆銆榪欐槸涓涓?C 紼嬪簭錛屾墍浠?CXXFLAGS 娌℃湁蹇呰璁劇疆——鍗充嬌琚緗簡(jiǎn)涔熶笉浼?xì)琚娇鐢ㄣ?/p>

銆銆緙栬瘧鍜岃繛鎺?GTK+ 搴撴墍闇瑕佺殑 CFLAGS 鍜?LDFLAGS 鐢?pkg-config 紼嬪簭鑷姩浜х敓銆?/p>

銆銆鐜板湪灝卞彲浠ヨ繍琛?make 鍛戒護(hù)緙栬瘧銆併?hello 鎵ц榪欎釜 GTK+ 紼嬪簭浜?jiǎn)銆?/p>

]]>
C++澶氱戶鎵夸腑鐨勪簩涔夋?http://www.shnenglu.com/idc/archive/2012/03/20/168443.html涓鍙惰崏涓鍙惰崏Tue, 20 Mar 2012 14:31:00 GMThttp://www.shnenglu.com/idc/archive/2012/03/20/168443.htmlhttp://www.shnenglu.com/idc/comments/168443.htmlhttp://www.shnenglu.com/idc/archive/2012/03/20/168443.html#Feedback0http://www.shnenglu.com/idc/comments/commentRss/168443.htmlhttp://www.shnenglu.com/idc/services/trackbacks/168443.html    澶氱戶鎵夸笅媧劇敓綾葷殑瀹氫箟鏍煎紡濡備笅錛?/p>

    class <媧劇敓綾誨悕>:<緇ф壙鏂瑰紡1><鍩虹被鍚?>,<緇ф壙鏂瑰紡2><鍩虹被鍚?>,…

    {

    <媧劇敓綾葷被浣?gt;

    };

    鍏朵腑錛?lt;緇ф壙鏂瑰紡1>,<緇ф壙鏂瑰紡2>,…鏄笁縐嶇戶鎵挎柟寮忥細(xì)public銆乸rivate銆乸rotected涔嬩竴銆備緥濡傦細(xì)

    class A

    {

    …

    };

    class B

    {

    …

    };

    class C : public A, public B

    {

    …

    };

    鍏朵腑錛屾淳鐢熺被C鍏鋒湁涓や釜鍩虹被錛堢被A鍜岀被B錛夛紝鍥犳錛岀被C鏄緇ф壙鐨勩傛寜鐓х戶鎵跨殑瑙勫畾錛屾淳鐢熺被C鐨勬垚鍛樺寘鍚簡(jiǎn)鍩虹被A, B涓垚鍛樹互鍙?qiáng)璇ゾc繪湰韜殑鎴愬憳銆?/p>

    澶氱戶鎵跨殑鏋勯犲嚱鏁?/p>

    鍦ㄥ緇ф壙鐨勬儏鍐典笅錛屾淳鐢熺被鐨勬瀯閫犲嚱鏁版牸寮忓涓嬶細(xì)

    <媧劇敓綾誨悕>錛?lt;鎬誨弬鏁拌〃>錛夛細(xì)<鍩虹被鍚?>錛?lt;鍙傛暟琛?>錛夛紝<鍩虹被鍚?>錛?lt;鍙傛暟琛?>錛夛紝…

    <瀛愬璞″悕>錛?lt;鍙傛暟琛╪+1>錛夛紝…

    {

    <媧劇敓綾繪瀯閫犲嚱鏁頒綋>

    }

    鍏朵腑錛?lt;鎬誨弬鏁拌〃>涓悇涓弬鏁板寘鍚簡(jiǎn)鍏跺悗鐨勫悇涓垎鍙傛暟琛ㄣ?/p>

    澶氱戶鎵夸笅媧劇敓綾葷殑鏋勯犲嚱鏁頒笌鍗曠戶鎵夸笅媧劇敓綾繪瀯閫犲嚱鏁扮浉浼鹼紝瀹冨繀欏誨悓鏃惰礋璐h媧劇敓綾繪墍鏈夊熀綾繪瀯閫犲嚱鏁扮殑璋冪敤銆傚悓鏃訛紝媧劇敓綾葷殑鍙傛暟涓暟蹇呴』鍖呭惈瀹屾垚鎵鏈夊熀綾誨垵濮嬪寲鎵闇鐨勫弬鏁頒釜鏁般?/p>

    媧劇敓綾繪瀯閫犲嚱鏁版墽琛岄『搴忔槸鍏堟墽琛屾墍灞炲熀綾葷殑鏋勯犲嚱鏁幫紝鍐嶆墽琛屾淳鐢熺被鏈韓鏋勯犲嚱鏁幫紝澶勪簬鍚屼竴灞傛鐨勫悇鍩虹被鏋勯犲嚱鏁扮殑鎵ц欏哄簭鍙栧喅浜庡畾涔夋淳鐢熺被鏃舵墍鎸囧畾鐨勫悇鍩虹被欏哄簭錛屼笌媧劇敓綾繪瀯閫犲嚱鏁頒腑鎵瀹氫箟鐨勬垚鍛樺垵濮嬪寲鍒楄〃鐨勫悇欏歸『搴忔棤鍏熾備篃灝辨槸璇達(dá)紝鎵ц鍩虹被鏋勯犲嚱鏁扮殑欏哄簭鍙栧喅浜庡畾涔夋淳鐢熺被鏃跺熀綾葷殑欏哄簭銆傚彲瑙侊紝媧劇敓綾繪瀯閫犲嚱鏁扮殑鎴愬憳鍒濆鍖栧垪琛ㄤ腑鍚勯」欏哄簭鍙互浠繪剰鍦版帓鍒椼?/p>

    涓嬮潰閫氳繃涓涓緥瀛愭潵璇存槑媧劇敓綾繪瀯閫犲嚱鏁扮殑鏋勬垚鍙?qiáng)鍏舵墽琛寵搴搴忋?/p>

    #include <iostream.h>

    class B1

    {

    public:

    B1錛坕nt i錛?/p>

    {

    b1 = i;

    cout銆?鏋勯犲嚱鏁?B1."銆奿銆?endl;

    }

    void print錛堬級(jí)

    {

    cout銆?B1.print錛堬級(jí)"銆奲1銆奺ndl;

    }

    private:

    int b1;

    };

    class B2

    {

    public:

    B2錛坕nt i錛?/p>

    {

    b2 = i;

    cout銆?鏋勯犲嚱鏁?B2."銆奿銆?endl;

    }

    void print錛堬級(jí)

    {

    cout銆?B2.print錛堬級(jí)"銆奲2銆奺ndl;

    }

    private:

    int b2;

    };

    class B3

    {

    public:

    B3錛坕nt i錛?/p>

    {

    b3 = i;

    cout銆?鏋勯犲嚱鏁?B3."銆奿銆奺ndl;

    }

    int getb3錛堬級(jí)

    {

    return b3;

    }

    private:

    int b3;

    };

    class A : public B2, public B1

    {

    public:

    A錛坕nt i, int j, int k, int l錛夛細(xì)B1錛坕錛夛紝 B2錛坖錛夛紝 bb錛坘錛?/p>

    {

    a = l;

    cout銆?鏋勯犲嚱鏁?A."銆奱銆奺ndl;

    }

    void print錛堬級(jí)

    {

    B1::print錛堬級(jí)錛?/p>

    B2::print錛堬級(jí)錛?/p>

    cout銆?A.print錛堬級(jí)"銆奱銆?,"銆奲b.getb3錛堬級(jí)銆奺ndl;

    }

    private:

    int a;

    B3 bb;

    };

    void main錛堬級(jí)

    {

    A aa錛?, 2, 3, 4錛夛紱

    aa.print錛堬級(jí)錛?/p>

    }


璇ョ▼搴忕殑杈撳嚭緇撴灉涓猴細(xì)

    鏋勯犲嚱鏁?B2.2

    鏋勯犲嚱鏁?B1.1

    鏋勯犲嚱鏁?B3.3

    鏋勯犲嚱鏁?A.4

    B1.print錛堬級(jí)銆?

    B2.print錛堬級(jí)2

    A.print錛堬級(jí)4, 3

    鍦ㄨ紼嬪簭涓紝浣滅敤鍩熻繍綆楃錛氾細(xì)鐢ㄤ簬瑙e喅浣滅敤鍩熷啿紿佺殑闂銆傚湪媧劇敓綾籄涓殑print錛堬級(jí)鍑芥暟鐨勫畾涔変腑錛屼嬌鐢ㄤ簡(jiǎn)B1::print;鍜孊2::print錛堬級(jí)錛涜鍙ュ垎鍒寚鏄庤皟鐢ㄥ摢涓涓被涓殑print錛堬級(jí)鍑芥暟錛岃繖縐嶇敤娉曞簲璇ュ浼?xì)銆?/p>

    浜屼箟鎬ч棶棰?/p>

    涓鑸鏉ワ紝鍦ㄦ淳鐢熺被涓鍩虹被鎴愬憳鐨勮闂簲璇ユ槸鍞竴鐨勶紝浣嗘槸錛岀敱浜庡緇ф壙鎯呭喌涓嬶紝鍙兘閫犳垚瀵瑰熀綾諱腑鏌愭垚鍛樼殑璁塊棶鍑虹幇浜?jiǎn)涓嶅敮涓鐨勬儏鍐碉紝鍒欑О涓哄鍩虹被鎴愬憳璁塊棶鐨勪簩涔夋ч棶棰樸?/p>

    瀹為檯涓婏紝鍦ㄤ笂渚嬪凡緇忓嚭鐜拌繃榪欎竴闂錛屽洖蹇嗕竴涓嬩笂渚嬩腑錛屾淳鐢熺被A鐨勪袱鍩虹被B1鍜孊2涓兘鏈変竴涓垚鍛樺嚱鏁皃rint錛堬級(jí)銆傚鏋滃湪媧劇敓綾諱腑璁塊棶 print錛堬級(jí)鍑芥暟錛屽埌搴曟槸鍝竴涓熀綾葷殑鍛紵浜庢槸鍑虹幇浜?jiǎn)浜屼箟鎬с備絾鏄湪涓婁緥涓В鍐充簡(jiǎn)榪欎釜闂錛屽叾鍔炴硶鏄氳繃浣滅敤鍩熻繍綆楃錛氾細(xì)榪涜浜?jiǎn)闄愬畾銆傚鏋滀笉鍔犱互闄愬畾錛屽垯浼?xì)鍑虹庮C簩涔夋ч棶棰樸?/p>

    涓嬮潰鍐嶄婦涓涓畝鍗曠殑渚嬪瓙錛屽浜屼箟鎬ч棶棰樿繘琛屾繁鍏ヨ璁恒備緥濡傦細(xì)

    class A

    {

    public:

    void f錛堬級(jí)錛?/p>

    };

    class B

    {

    public:

    void f錛堬級(jí)錛?/p>

    void g錛堬級(jí)錛?/p>

    };

    class C : public A, public B

    {

    public:

    void g錛堬級(jí)錛?/p>

    void h錛堬級(jí)錛?/p>

    };

    濡傛灉瀹氫箟涓涓被C鐨勫璞1:

    C c1;

    鍒欏鍑芥暟f錛堬級(jí)鐨勮闂?/p>

    c1.f錛堬級(jí)錛?/p>

    渚垮叿鏈変簩涔夋э細(xì)鏄闂被A涓殑f錛堬級(jí)錛岃繕鏄闂被B涓殑f錛堬級(jí)鍛紵

    瑙e喅鐨勬柟娉曞彲鐢ㄥ墠闈㈢敤榪囩殑鎴愬憳鍚嶉檺瀹氭硶鏉ユ秷闄や簩涔夋э紝渚嬪錛?/p>

    c1.A::f錛堬級(jí)錛?/p>

    鎴栬?/p>

    c1.B::f錛堬級(jí)錛?/p>

    浣嗘槸錛屾渶濂界殑瑙e喅鍔炴硶鏄湪綾籆涓畾涔変竴涓悓鍚嶆垚鍛榝錛堬級(jí)錛岀被C涓殑f錛堬級(jí)鍐嶆牴鎹渶瑕佹潵鍐沖畾璋冪敤A::f錛堬級(jí)錛岃繕鏄疊::f錛堬級(jí)錛岃繕鏄袱鑰呯殕鏈夛紝榪欐牱錛宑1.f錛堬級(jí)灝嗚皟鐢–::f錛堬級(jí)銆?/p>

    鍚屾牱鍦幫紝綾籆涓垚鍛樺嚱鏁拌皟鐢╢錛堬級(jí)涔熶細(xì)鍑虹幇浜屼箟鎬ч棶棰樸備緥濡傦細(xì)

    viod C::h錛堬級(jí)

    {

    f錛堬級(jí)錛?/p>

    }

    榪欓噷鏈変簩涔夋ч棶棰橈紝璇ュ嚱鏁板簲淇敼涓猴細(xì)

    void C::h錛堬級(jí)

    {

    A::f錛堬級(jí)錛?/p>

    }

    鎴栬?/p>

    void C::h錛堬級(jí)

    {

    B::f錛堬級(jí)錛?/p>

    }

    鎴栬?/p>

    void C::f錛堬級(jí)

    {

    A::f錛堬級(jí)錛?/p>

    B::f錛堬級(jí)錛?/p>

    }

    鍙﹀錛屽湪鍓嶄緥涓紝綾籅涓湁涓涓垚鍛樺嚱鏁癵錛堬級(jí)錛岀被C涓篃鏈変竴涓垚鍛樺嚱鏁癵錛堬級(jí)銆傝繖鏃訛紝

    c1.g錛堬級(jí)錛?/p>

    涓嶅瓨鍦ㄤ簩涔夋э紝瀹冩槸鎸嘋::g錛堬級(jí)錛岃屼笉鏄寚B::g錛堬級(jí)銆傚洜涓鴻繖涓や釜g錛堬級(jí)鍑芥暟錛屼竴涓嚭鐜板湪鍩虹被B錛屼竴涓嚭鐜板湪媧劇敓綾籆錛岃瀹氭淳鐢熺被鐨勬垚鍛樺皢鏀厤鍩虹被涓殑鍚屽悕鎴愬憳銆傚洜姝わ紝涓婁緥涓被C涓殑g錛堬級(jí)鏀厤綾籅涓殑g錛堬級(jí)錛屼笉瀛樺湪浜屼箟鎬э紝鍙夋嫨鏀厤鑰呯殑閭d釜鍚嶅瓧銆?/p>

    褰撲竴涓淳鐢熺被浠庡涓熀綾繪淳鐢熺被錛岃岃繖浜涘熀綾誨張鏈変竴涓叡鍚岀殑鍩虹被錛屽垯瀵硅鍩虹被涓鏄庣殑鎴愬憳榪涜璁塊棶鏃訛紝涔熷彲鑳戒細(xì)鍑虹幇浜屼箟鎬с備緥濡傦細(xì)

    class A

    {

    public:

    int a;

    };

    class B1 : public A

    {

    private:

    int b1;

    };

    class B2 : public A

    {

    private:

    int b2;

    };

    class C : public B1, public B2

    {

    public:

    int f錛堬級(jí)錛?/p>

    private:

    int c;

    };

    宸茬煡錛欳 c1;

    涓嬮潰鐨勪袱涓闂兘鏈変簩涔夋э細(xì)

    c1.a;

    c1.A::a;

    鑰屼笅闈㈢殑涓や釜璁塊棶鏄紜殑錛?/p>

    c1.B1::a;

    c1.B2::a;

    綾籆鐨勬垚鍛樺嚱鏁癴錛堬級(jí)鐢ㄥ涓嬪畾涔夊彲浠ユ秷闄や簩涔夋э細(xì)

    int C::f錛堬級(jí)

    {

    retrun B1::a + B2::a;

    }

    鐢變簬浜屼箟鎬х殑鍘熷洜錛屼竴涓被涓嶅彲浠ヤ粠鍚屼竴涓被涓洿鎺ョ戶鎵夸竴嬈′互涓婏紝渚嬪錛?/p>

    class A : public B, public B

    {

    …

    }

    榪欐槸閿欒鐨勩?/p>

]]>
灝哊涓疄鏁扮敱澶у埌灝忔帓搴?/title><link>http://www.shnenglu.com/idc/archive/2012/03/18/168249.html</link><dc:creator>涓鍙惰崏</dc:creator><author>涓鍙惰崏</author><pubDate>Sun, 18 Mar 2012 05:31:00 GMT</pubDate><guid>http://www.shnenglu.com/idc/archive/2012/03/18/168249.html</guid><wfw:comment>http://www.shnenglu.com/idc/comments/168249.html</wfw:comment><comments>http://www.shnenglu.com/idc/archive/2012/03/18/168249.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/idc/comments/commentRss/168249.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/idc/services/trackbacks/168249.html</trackback:ping><description><![CDATA[鍛靛懙錛屾渶榪戝嚑澶╂垜鏈変釜灝忓彂鐜幫紝閭e氨鏄佺櫧娌℃湁鏉ョ湅榪囨垜鐨勫崥瀹簡(jiǎn)錛岃鐪熺殑铔笇鏈涗粬鑳芥潵鐨勶紝 <div>浠栦笉鏉ユ湁鐐硅鎴戝け鏈涳紝姣曠珶鎴戜篃鍏蟲敞浠栧緢闀夸竴孌墊椂闂翠簡(jiǎn)錛屽綋鐒?dòng)灱屼笉绠′粬鏉ヤ笉鏉ュQ屾垜鑷繁鐨勫伐浣滆繕鏄緱緇х畫涓嬪幓鐨勫槢涓紝瀵逛笉瀵癸紝榪欓噷鎴戝皢綆鍗曞浜庡皢n涓疄鏁扮敱澶у埌灝忔帓搴忓仛涓粙緇嶅惂銆?/div> <div>    n涓疄鏁扮敤鏁扮粍a鎻忚堪銆?br />    鏈緥鎻愪緵鐢ㄩ夋嫨鎺掑簭鏂規(guī)硶涓庡啋娉℃帓搴忔柟娉曞垎鍒疄鐜皀涓疄鏁扮敱澶у埌灝忔帓搴忕殑鍑芥暟銆?br />    綆楁硶涓錛氶夋嫨鎺掑簭銆?br />    閫夋嫨鎺掑簭闇鍙嶅榪涜姹傛渶澶у間笌浜ゆ崲涓や釜鏁拌繖涓ょ鍩烘湰鎿嶄綔銆?br />    瀵筧[o]銆乤[1]銆?#8230;銆乤[n涓1]鐢卞ぇ鍒板皬鎺掑簭錛氬厛姹傛墍鏈夋暟鐨勬渶澶у鹼紝鐒跺悗灝嗘渶澶у間笌a[o]榪涜浜ゆ崲錛涘啀姹俛[1]锝瀉[n涓1]榪欎簺鏁扮殑鏈澶у鹼紝鐒跺悗灝嗘渶澶у間笌a[1]榪涜浜ゆ崲錛涘啀姹俛[2]锝瀉[n涓1]榪欎簺鏁扮殑鏈澶у鹼紝鐒跺悗灝嗘渶澶у間笌a[2]榪涜浜ゆ崲……錛涙渶鍚庢眰a[n涓2]涓巃[n涓1]榪欎簺鏁扮殑鏈澶у鹼紝鐒跺悗灝嗘渶澶у間笌a[n涓2]榪涜浜ゆ崲銆傚姝わ紝緇忚繃n涓1杞鐞嗗畬鎴愭帓搴忥紝鏈枃棣栧彂涓浗鑷緙栫▼緗戙?br />    紼嬪簭濡備笅錛?br />    void sortl(a錛宯)錛?閫夋嫨鎺掑簭鍑芥暟*錛?br />    float a[]錛?br />    int n錛?br />    {int k錛宨錛宩錛涳紡*k鏈澶у間笅鏍囷紝i錛宩寰幆鎺у埗鍙橀噺*錛?br />    float t錛涳紡*涓棿鍙橀噺錛岀敤浜庝袱涓暟鐨勪氦鎹?錛?br />    for(i=0錛沬<n-1錛沬++)<br />    {k=i錛涳紡*姹傛渶澶у間笅鏍?錛?br />    for(j=i+1}j<n錛沯++)<br />    if(a[j]>a[k])k=j</div> <div>    t=a[i]錛沘[i]涓a[k];a[k]=t錛涳紡*榪涜浜ゆ崲*錛?br />    }<br />    }<br />    綆楁硶浜岋細(xì)鍐掓場(chǎng)鎺掑簭銆?br />    鍐掓場(chǎng)鎺掑簭闇鍙嶅榪涜鐩擱偦涓や釜鏁扮殑姣旇緝涓庝氦鎹袱涓暟榪欎袱縐嶅熀鏈搷浣溿傚鐩擱偦鐨勪袱涓暟榪涜姣旇緝鏃訛紝濡傛灉鍚庨潰鐨勬暟澶т簬鍓嶉潰鐨勬暟錛屽皢榪欎袱涓暟榪涜浜ゆ崲錛屽ぇ鐨勬暟寰鍓嶅啋銆傚皢鎵鏈夌浉閭?cè)潥勪袱涓?font color="black">瀹夊叏闃</font>鏁版瘮杈冧竴閬嶏紝縐頒負(fù)涓杞瘮杈冦傚鏋滆繘琛屼竴杞瘮杈冩棤浜ゆ崲錛屾湰鏂囬鍙戜腑鍥借嚜瀛︾紪紼嬬綉鎺掑簭瀹屾垚銆?br />    鏈夋棤浜ゆ崲鐢ㄤ竴鏍囧織鍙橀噺鎻忚堪錛屼竴杞瘮杈冪敤for寰幆瀹屾垚錛屾暣涓帓搴忓埄鐢ㄦ爣蹇楀彉閲忕敤鏉′歡寰幆鎺у埗銆?br />    紼嬪簭濡備笅錛?br />    void sort2(a錛宯)錛?鍐掓場(chǎng)鎺掑簭鍑芥暟*錛?br />    float a[]錛?br />    int n錛?br />    {int i錛涳紡*涓杞瘮杈冪殑寰幆鎺у埗鍙橀噺*錛?br />    int flag錛涳紡*鏍囧織鍙橀噺錛屼負(fù)1鏈変氦鎹紝涓?鏃犱氦鎹?錛?br />    float t錛涳紡*涓棿鍙橀噺錛岀敤浜庝袱涓暟鐨勪氦鎹?錛?br />    do<br />    {flag=O錛涳紡*鍏堝亣瀹氭棤浜ゆ崲錛屽凡鎺掑ソ搴?錛?br />    for(i=O錛沬<n涓2錛?i++)<br />    if(a[i+1]>a[i])<br />    {t=a[i]錛沘[i]=a[i+1]錛沘[i+1]=t錛涳紡*榪涜浜ゆ崲*錛?br />    flag=1錛涳紡*鏈変氦鎹紝鏍囧織鍙橀噺鐨勫兼敼鍙樹負(fù)1*錛?br />    }<br />    }while(flag==1)錛?br />    )<br />    鐢卞皬鍒板ぇ鎺掑簭璇瘋鑰呬綔綾諱技鑰冭檻銆傚懙鍛碉紝宸笉澶氫簡(jiǎn)錛屽鏋滄湁涓嶅綋涔嬪錛岃鏈嬪弸浠寚姝e晩---</div><img src ="http://www.shnenglu.com/idc/aggbug/168249.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/idc/" target="_blank">涓鍙惰崏</a> 2012-03-18 13:31 <a href="http://www.shnenglu.com/idc/archive/2012/03/18/168249.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>c璇█涓綅孌電殑浣跨敤http://www.shnenglu.com/idc/archive/2012/03/11/167661.html涓鍙惰崏涓鍙惰崏Sun, 11 Mar 2012 09:35:00 GMThttp://www.shnenglu.com/idc/archive/2012/03/11/167661.htmlhttp://www.shnenglu.com/idc/comments/167661.htmlhttp://www.shnenglu.com/idc/archive/2012/03/11/167661.html#Feedback0http://www.shnenglu.com/idc/comments/commentRss/167661.htmlhttp://www.shnenglu.com/idc/services/trackbacks/167661.html    鍚湁浣嶆鐨勭粨鏋勪綋綾誨瀷縐頒負(fù)浣嶆緇撴瀯銆?/p>

    浣嶆緇撴瀯涔熸槸涓縐嶇粨鏋勪綋綾誨瀷錛屽彧涓嶈繃鍏朵腑鍚湁浠ヤ綅涓哄崟浣嶅畾涔夊瓨鍌ㄩ暱搴︾殑鏁存暟綾誨瀷浣嶆鎴愬憳銆傞噰鐢ㄤ綅孌電粨鏋勬棦鑺傜渷瀛樺偍絀洪棿錛屽張鍙柟渚挎搷浣溿?/p>

    浣嶆緇撴瀯涓綅孌電殑瀹氫箟鏍煎紡涓猴細(xì)

    unsigned <鎴愬憳鍚?gt;:<浜岃繘鍒朵綅鏁?gt;

    渚嬪錛?/p>

    struct bytedata

    {unsigned a:2;   /*浣嶆a錛屽崰2浣?/

    unsigned:6;  /*鏃犲悕浣嶆錛屽崰6浣嶏紝浣嗕笉鑳借闂?/

    unsigned:0;     /*鏃犲悕浣嶆錛屽崰0浣嶏紝琛ㄤ笅涓浣嶆浠庝笅涓瀛楄竟鐣屽紑濮?/

    unsigned b:10;  /*浣嶆b錛屽崰10浣?/

    int i;          /*鎴愬憳i錛屼粠涓嬩竴瀛楄竟鐣屽紑濮?/

    }data;

    浣嶆鏁版嵁鐨勫紩鐢細(xì)

    鍚岀粨鏋勪綋鎴愬憳涓殑鏁版嵁寮曠敤涓鏍鳳紝浣嗗簲娉ㄦ剰浣嶆鐨勬渶澶у彇鍊艱寖鍥翠笉瑕佽秴鍑轟簩榪涘埗浣嶆暟瀹氱殑鑼冨洿錛屽惁鍒欒秴鍑洪儴鍒嗕細(xì)涓㈠純銆?/p>

    渚嬪錛歞ata.a=2;   浣?nbsp; data.a=10;灝辮秴鍑鴻寖鍥達(dá)紙a鍗?浣嶏紝鏈澶?錛?/p>

    鍏充簬浣嶆鏁版嵁錛屾敞鎰忎互涓嬪嚑鐐癸細(xì)

    錛?錛変竴涓綅孌靛繀欏誨瓨鍌ㄥ湪鍚屼竴瀛樺偍鍗曞厓錛堝嵆瀛楋級(jí)涔嬩腑錛屼笉鑳借法涓や釜鍗曞厓銆傚鏋滃叾鍗曞厓絀洪棿涓嶅錛屽垯鍓╀綑絀洪棿涓嶇敤錛屼粠涓嬩竴涓崟鍏冭搗瀛樻斁璇ヤ綅孌點(diǎn)?/p>

    錛?錛夊彲浠ラ氳繃瀹氫箟闀垮害涓?鐨勪綅孌電殑鏂瑰紡浣夸笅涓浣嶆浠庝笅涓瀛樺偍鍗曞厓寮濮嬨?/p>

    錛?錛夊彲浠ュ畾涔夋棤鍚嶄綅孌點(diǎn)?/p>

    錛?錛変綅孌電殑闀垮害涓嶈兘澶т簬瀛樺偍鍗曞厓鐨勯暱搴︺?/p>

    錛?錛変綅孌墊棤鍦板潃錛屼笉鑳藉浣嶆榪涜鍙栧湴鍧榪愮畻銆?/p>

    錛?錛変綅孌靛彲浠ヤ互%d錛?o錛?x鏍煎紡杈撳嚭銆?/p>

    錛?錛変綅孌佃嫢鍑虹幇鍦ㄨ〃杈懼紡涓紝灝嗚緋葷粺鑷姩杞崲鎴愭暣鏁般?/p>

    -------------------------------------------------------

    C璇█涓敤緇撴瀯瀹炵幇浣嶆錛嶏紞涓漢蹇?jī)琛錛佸煎緱涓鐪嬪摝錛丆璇█涓殑緇撴瀯鏄湁瀹炵幇浣嶆鐨勮兘鍔涚殑錛屽櫌錛佷綘闂畠鍒板簳鏄粈涔堝艦寮忔槸鍚э紵榪欎釜闂鍛嗕細(xì)緇欎綘絳旀銆傝鎴戜滑鍏堢湅鐪嬩綅孌電殑浣滅敤錛氫綅孌墊槸鍦ㄥ瓧孌電殑澹版槑鍚庨潰鍔犱竴涓啋鍙蜂互鍙?qiáng)涓涓〃紺哄瓧孌典綅闀跨殑鏁存暟鏉ュ疄鐜扮殑銆傝繖縐嶇敤娉曞張琚氨鍙綔“娣卞叆閫昏緫鍏冧歡鐨勭紪紼?#8221;錛屽鏋滀綘瀵圭郴緇熺紪紼嬫劅鍏磋叮錛岄偅涔堣繖綃囨枃绔犱綘灝變笉搴旇閿欒繃錛?/p>

    鎴戞妸浣跨敤浣嶆鐨勫嚑涓悊鐢卞憡璇夊ぇ瀹訛細(xì)1銆佸畠鑳芥妸闀垮害涓哄鏁扮殑鏁版嵁鍖呰鍦ㄤ竴璧鳳紝浠庤岃妭鐪佸瓨鍌ㄧ殑絀洪棿錛?銆佸畠鍙互寰堟柟渚垮湴璁塊棶涓涓暣鍨嬪肩殑閮ㄥ垎鍐呭銆?/p>

    棣栧厛鎴戣鎻愰啋澶у娉ㄦ剰鍑犵偣錛?銆佷綅孌墊垚鍛樺彧鏈変笁縐嶇被鍨嬶細(xì)int ,unsigned int 鍜宻igned int榪欎笁縐嶏紙褰撶劧浜?jiǎn)锛宨nt鍨嬩綅孌墊槸涓嶆槸鍙互鍙栬礋鏁頒笉鏄垜璇翠簡(jiǎn)綆楃殑錛屽洜涓鴻繖鏄拰浣犵殑緙栬瘧鍣ㄦ潵鍐沖畾鐨勩備綅孌碉紝浣嶆錛屽畠鏄敤鏉ヨ〃紺哄瓧孌典綅闀匡紙bit錛夌殑錛屽畠鍙湁鏁村瀷鍊鹼紝涓嶄細(xì)鏈?.2榪欑float綾誨瀷鐨勶紝濡傛灉浣犺鏈夛紝閭d綘灝辯瓑浜庢壙璁や簡(jiǎn)鏈?.2涓漢榪欎釜姒傚康錛屽綋鐒朵篃娌℃湁char榪欎釜綾誨瀷鐨勶級(jí)錛?銆佹垚鍛樺悕鍚庨潰鐨勪竴涓啋鍙峰拰涓涓暣鏁幫紝榪欎釜鏁存暟鎸囧畾璇ヤ綅孌電殑浣嶉暱錛坆it錛夛紱3銆佽澶氱紪璇戝櫒鎶婁綅孌墊垚鍛樼殑瀛楅暱闄愬埗鍦ㄤ竴涓猧nt鐨勯暱搴﹁寖鍥翠箣鍐咃紱4銆佷綅孌墊垚鍛樺湪鍐呭瓨鐨勫疄鐜版槸浠庡乏鍒板彸榪樻槸浠庡彸鍒板乏鏄敱緙栬瘧鍣ㄦ潵鍐沖畾鐨勶紝浣嗕簩鑰呯殕瀵廣?/p>

    涓嬮潰鎴戜滑灝辨潵鐪嬬湅錛屽畠鍒板簳鏄粈涔堜笢瑗匡紙鎴戝厛鍋囧畾澶у鐨勬満鍣ㄥ瓧闀夸負(fù)32浣嶏級(jí)錛?/p>

    Struct WORD

    {

    unsigned int chara: 6:

    unsigned int font : 7;

    unsigned int maxsize : 19;

    };

    Struct WORD chone;

    榪欎竴孌墊槸浠庢垜緙栧啓鐨勪竴涓枃瀛楁牸寮忓寲杞歡鎽樹笅鏉ョ殑錛屽畠鏈澶氬彲浠ュ綰?4錛堟棦鎴戣鐨剈nsigned int chara :6; 瀹冩誨叡鏄?浣嶏級(jí)涓笉鍚岀殑瀛楃鍊鹼紝鍙互澶勭悊128錛堟棦unsigned int font : 7 ;鏃?鐨?嬈℃柟錛夌涓嶅悓鐨勫瓧浣擄紝鍜?鐨?9嬈℃柟鐨勫崟浣嶉暱搴︾殑瀛椼傚ぇ瀹墮兘鍙互鐪嬪埌maxsize鏄?9浣嶏紝瀹冩槸鏃犳硶琚竴涓猻hort int 綾誨瀷鐨勫兼墍瀹圭撼鐨勶紝鎴戜滑鍙堝彲浠ョ湅鍒板叾浣欑殑鎴愬憳鐨勯暱搴︽瘮char榪樺皬錛岃繖灝辮鎴戜滑鎯寵搗璁╀粬浠叡浜?2浣嶆満鍣ㄥ瓧闀匡紝榪欏氨閬垮厤鐢ㄤ竴涓?2浣嶇殑鏁存暟鏉ヨ〃紺簃axsize鐨勪綅孌點(diǎn)傛庝箞鏍鳳紵榪樿娉ㄦ剰鐨勬槸鍒氭墠鐨勯偅涓孌典唬鐮佸湪16浣嶅瓧闀跨殑鏈哄櫒涓婃槸鏃犳硶瀹炵幇鐨勶紝涓轟粈涔堬紵鎻愰啋浣犱竴涓嬶紝鐪嬬湅涓婇潰鎻愰啋鐨勭3鐐癸紝浣犱細(xì)鏄庣櫧鐨勶紒

    浣犳槸涓嶆槸鍙戠幇榪欎釜涓滆タ娌℃湁鐢ㄥ晩錛熷鏋滀綘鐐瑰ご浜?jiǎn)锛岄偅浣牉閿欎簡(jiǎn)锛仒q欎箞浼熷ぇ鐨勫垱閫犳庝箞浼?xì)娌℃湁鐢ㄥ憿锛堜綘瀵咕p葷粺緙栫▼涓嶆劅鍏磋叮錛岀浉淇′綘浼?xì)鏀瑰彉杩欎箞涓涓鐐圭殑錛夛紵紓佺洏鎺у埗鍣ㄥぇ瀹跺簲璇ョ煡閬撳惂錛熻蔣椹變笌瀹冪殑閫氫俊鎴戜滑鏉ョ湅鐪嬫槸鎬庝箞瀹炵幇鐨勪笅闈㈡槸涓涓鐩樻帶鍒跺櫒鐨勫瘎瀛樺櫒錛?/p>

    │←5→│←5→│←9→│←8→│←1→│←1→∣←1→∣←1→∣←1→∣

    涓婇潰浣嶆浠庡乏鍒板彸渚濇浠h〃鐨勫惈涔変負(fù)錛?浣嶇殑鍛戒護(hù)錛?浣嶇殑鎵囧尯錛?浣嶇殑紓侀亾錛?浣嶇殑閿欒浠g爜錛?浣嶇殑HEAD LOADED,1浣嶇殑鍐欎繚鎶わ紝1浣嶇殑DISK SPINNING錛?浣嶇殑閿欒鍒ゆ柇絎︼紝榪樻湁1浣嶇殑READY浣嶃傚畠瑕佹庝箞鏉ュ疄鐜板憿錛熶綘鍏堣嚜宸卞啓鍐欑湅錛?/p>

    struct DISK_FORMAT

    {

    unsigned int command : 5;

    unsigned sector : 5;

    unsigned track : 9 ;

    unsigned err_code : 8;

    unsigned ishead_loaded : 1;

    unsigned iswrit_protect : 1;

    unsigned isdisk_spinning : 1;

    unsigned iserr_ocur : 1;

    undigned isready :1 ;

    };

    娉細(xì)浠g爜涓櫎浜?jiǎn)绗竴琛屼嬌鐢ㄤ簡(jiǎn)unsigned int 鏉ュ0鏄庝綅孌靛悗灝辯渷鍘諱簡(jiǎn)int 錛岃繖鏄彲琛岀殑錛岃瑙丄NCI C鏍囧噯銆?/p>

    濡傛灉鎴戜滑瑕佸044c18bfH鐨勫湴鍧榪涜璁塊棶鐨勮瘽錛岄偅灝辮繖鏍鳳細(xì)

    #define DISK 錛堬紙struct DISK_FORMAT *錛?x044c18bf錛?/p>

    DISK->sector=fst_sector;

    DISK->track=fst_track;

    DISK->command=WRITE;

    褰撶劧閭d簺閮芥槸瑕佸畯瀹氫箟鐨勫摝錛?/p>

    鎴戜滑鐢ㄤ綅孌墊潵瀹炵幇榪欎竴鐩殑鏄緢鏂逛究鐨勶紝鍏跺疄榪欎篃鍙互鐢ㄧЩ浣嶆垨灞忚斀鏉ュ疄鐜幫紝浣犲皾璇曡繃灝辯煡閬撳摢涓洿鏂逛究浜?jiǎn)锛?/p>

]]>
C++涓嬌鐢‥xpat瑙f瀽XML http://www.shnenglu.com/idc/archive/2012/02/26/166554.html涓鍙惰崏涓鍙惰崏Sun, 26 Feb 2012 05:31:00 GMThttp://www.shnenglu.com/idc/archive/2012/02/26/166554.htmlhttp://www.shnenglu.com/idc/comments/166554.htmlhttp://www.shnenglu.com/idc/archive/2012/02/26/166554.html#Feedback0http://www.shnenglu.com/idc/comments/commentRss/166554.htmlhttp://www.shnenglu.com/idc/services/trackbacks/166554.html浣跨敤expat鐨勫師鍥犲緢澶氾紝涓昏榪樻槸鍥犱負(fù)expat鏇寸伒媧匯備範(fàn)鎯簡(jiǎn)TinyXML錛屼竴寮濮嬩笉澶範(fàn)鎯痚xpat錛屽垎鏋愪竴涓嬶紝鍏跺疄寰堝鏄撲笂鎵嬬殑銆?

    1.鍥炶皟鍑芥暟

    浠ヤ笅妗堜緥瑙f瀽xml鏂囦歡涓殑elment錛宎ttribute鍜宼ext銆俥xpat浣跨敤鍥炶皟鏂瑰紡榪斿洖xml鏁版嵁錛岃В鏋愬櫒瑙f瀽鍒頒竴涓猠lement鍙?qiáng)鍏跺唴閮ㄥ睘鎬у悗錛屽皢璋冪敤浜嬪厛璁劇疆濂界殑鍑芥暟錛屽悓鏍鳳紝褰揺lement緇撴潫鍜宼ext緇撴潫鍚庯紝涔熶細(xì)鍒嗗埆璋冪敤瀵瑰簲鐨勫嚱鏁般?/span>

    2.濡備綍澶勭悊鏁版嵁涔嬮棿鐨勫寘鍚叧緋?/span>

    鍏稿瀷鐨勬柟寮忔槸瀹氫箟涓変釜鍑芥暟鍒嗗埆澶勭悊elment寮濮嬶紙鍚睘鎬э級(jí)銆乪lement緇撴潫鍜屾枃鏈唴瀹廣傚洖璋冨嚱鏁扮殑絎竴涓弬鏁版槸鑷畾涔夌殑錛岄氬父鐢ㄤ簬瀛樺偍 XML鏂囨。鐨勪笂涓嬫枃淇℃伅錛岀敤XML_SetUserData鍙互璁劇疆榪欎釜鍙傛暟錛屼笅渚嬩腑浼犻掍竴涓暣鏁版寚閽堬紝浠ヤ究鍦ㄦ瘡嬈″洖璋冩椂鑳界煡閬撹鍏冪礌鏄鍑犲眰鍏冪礌銆?/span>

    璇ュ弬鏁頒篃鍙互鏄竴涓爤瀵硅薄鐨勫湴鍧錛屽紑濮嬩竴涓厓绱犳椂錛屽皢鏂板厓绱犲搴旂殑鏁版嵁鍘嬪叆鍫嗘爤錛屽鐞嗕笅涓綰у厓绱犳椂錛屾柊鍏冪礌鏄爤欏跺厓绱犲湪瀛愬厓绱狅紝鐒跺悗澶勭悊瀹屼簡(jiǎn)緇х畫鎶婅鍏冪礌鍘嬪叆鍫嗘爤錛岀戶緇笅涓綰ф柊鐨勫瓙鍏冪礌銆傚綋鍏冪礌緇撴潫鍚庯紝闇瑕佸嚭鏍堬紝浠ヤ究瑙f瀽涓嬩釜鍏勫紵鍏冪礌紼嬫椂鑳藉彇鍒扮埗鑺傜偣銆?/span>

    濂藉暒錛屽熀鏈簲鐢ㄨ繕鏄緢綆鍗曠殑錛屽疄闄呬笂Expat鐨凙PI鍑芥暟涓嶅銆?/span>

    3.濡備綍澶勭悊灞炴?/span>

    灞炴ч氳繃ElementHandler鍥炶皟鍑芥暟浼犲叆錛岃繖閲屾湁涓涓猚har** atts灝辨槸灞炴э紝榪欐槸涓涓瓧絎︽寚閽堟暟緇勶紝濡傛灉鏈塏涓睘鎬э紝鏁扮粍澶у皬灝辨槸2*N+1錛屾渶鍚庝竴涓礌緇勫厓绱犱負(fù)絀烘寚閽堬紝濂囨暟鎸囬拡瀵瑰簲灞炴у悕縐幫紝鍋舵暟鎸囬拡瀵瑰簲灞炴у鹼紙瀛楃涓叉牸寮忥級(jí)銆傚彲浠ュ湪涓涓驚鐜腑澶勭悊澶氫釜灞炴э紝褰撻亣鍒扮┖鎸囬拡鏃訛紝琛ㄧず娌℃湁鏇村灞炴т簡(jiǎn)銆?/span>

    濂藉暒錛屽厛鐪媠ample鍚э細(xì)

    #include銆<stdio.h>

    #include銆"expat.h"

    #pragma銆warning錛坉isable:4996錛?/span>

    #define銆XML_FMT_INT_MOD銆"l"

    static銆void銆XMLCALL銆startElement錛坴oid銆*userData,銆const銆char銆*name,銆const銆char銆**atts錛?/span>

    {

    int銆i;

    int銆*depthPtr銆=銆錛坕nt銆*錛塽serData;

    for銆錛坕銆=銆0;銆i銆<銆*depthPtr;銆i++錛?/span>

    printf錛?銆"錛夛紱

    printf錛坣ame錛夛紱

    *depthPtr銆+=銆1;

    for錛坕=0;atts[i]!=0;i+=2錛?/span>

    {

    printf錛?銆%s=%s",atts[i],atts[i+1]錛夛紱

    }

    printf錛?\n"錛夛紱

    }

    static銆void銆XMLCALL銆endElement錛坴oid銆*userData,銆const銆char銆*name錛?/span>

    {

    int銆*depthPtr銆=銆錛坕nt銆*錛塽serData;

    *depthPtr銆-=銆1;

    }

    int銆main錛坕nt銆argc,銆char銆*argv[]錛?/span>

    {

    char銆buf[BUFSIZ];銆銆XML_Parser銆parser銆=銆XML_ParserCreate錛圢ULL錛夛紱

    int銆done;銆銆int銆depth銆=銆0;

    XML_SetUserData錛坧arser,銆&depth錛夛紱

    XML_SetElementHandler錛坧arser,銆startElement,銆endElement錛夛紱

    FILE*銆pFile=銆argc<2銆?stdin銆:銆fopen錛坅rgv[1],"rb"錛夛紱

    do

    {銆銆銆銆int銆len銆=銆錛坕nt錛塮read錛坆uf,銆1,銆sizeof錛坆uf錛夛紝銆pFile錛夛紱

    done銆=銆len銆<銆sizeof錛坆uf錛夛紱

    if銆錛圶ML_Parse錛坧arser,銆buf,銆len,銆done錛夈==銆XML_STATUS_ERROR錛?/span>

    {

    fprintf錛坰tderr,"%s銆at銆line銆%"銆XML_FMT_INT_MOD銆"u\n",

    XML_ErrorString錛圶ML_GetErrorCode錛坧arser錛夛級(jí)錛?/span>

    XML_GetCurrentLineNumber錛坧arser錛夛級(jí)錛?/span>

    return銆1;

    }

    }

    while銆錛堬紒done錛夛紱

    XML_ParserFree錛坧arser錛夛紱

    fclose錛坧File錛夛紱

    return銆0;

    }

    4.鍏朵粬ElementHanlder

    expat榪樺彲浠ヨ緗瓹Data錛孋omment鐨刪andler錛屽彟澶栦竴浜涘嚱鏁版湰浜鴻繕娌′嬌鐢ㄨ繃錛屾秹鍙?qiáng)鍒版洿澶氱殑xml鏍囧噯鐨勭煡璇嗭紝濡傛灉闇瑕侊紝鍙互鍙傝冨畼鏂圭殑鎵嬪唽銆?/span>



]]>
c++ 澶勭悊Json http://www.shnenglu.com/idc/archive/2012/02/22/166226.html涓鍙惰崏涓鍙惰崏Wed, 22 Feb 2012 04:31:00 GMThttp://www.shnenglu.com/idc/archive/2012/02/22/166226.htmlhttp://www.shnenglu.com/idc/comments/166226.htmlhttp://www.shnenglu.com/idc/archive/2012/02/22/166226.html#Feedback0http://www.shnenglu.com/idc/comments/commentRss/166226.htmlhttp://www.shnenglu.com/idc/services/trackbacks/166226.html涓銆佹憳瑕?/strong>

JSON 鐨勫叏縐頒負(fù)錛欽avaScript Object Notation錛岄【鍚嶆濅箟錛孞SON 鏄敤浜庢爣璁?Javascript 瀵硅薄鐨勶紝JSON 瀹樻柟鐨勮В閲婁負(fù)錛欽SON 鏄竴縐嶈交閲忕駭鐨勬暟鎹紶杈撴牸寮忋?/p>

鏈枃騫朵笉璇︾粏浠嬬粛 JSON 鏈韓鐨勭粏鑺傦紝鏃ㄥ湪璁ㄨ濡備綍浣跨敤 C++ 璇█鏉ュ鐞?JSON銆傚叧浜?JSON 鏇村叿浣撶殑淇℃伅錛屽彲鍙傝 JSON 瀹樼綉錛歨ttp://www.json.org銆?/p>

浜屻佹湰鏂囬夋嫨澶勭悊 JSON鐨?/strong> C++ 搴?/strong>

鏈枃閫夋嫨涓涓涓夋柟搴?jsoncpp 鏉ヨВ鏋?JSON銆俲soncpp 鏄瘮杈冨嚭鍚嶇殑 C++ JSON 瑙f瀽搴撱傚湪 JSON 瀹樼綉涔熸槸棣栨帹鐨勩?/p>

涓嬭澆鍦板潃涓猴細(xì)http://sourceforge.net/projects/jsoncpp銆傛湰鏂囦嬌鐢ㄧ殑 jsoncpp 鐗堟湰涓猴細(xì)0.5.0銆?/p>

涓夈?/strong>jsoncpp 鍦?/strong> Windows 涓嬬殑緙栬瘧

瑕佷嬌鐢ㄧ涓夋柟婧愮爜搴擄紝絎竴姝ュ皯涓嶄簡(jiǎn)鐨勫氨鏄紪璇戯紝灝嗘簮鐮佹枃浠剁紪璇戞垚鎴戜滑鏂逛究浣跨敤鐨勫姩鎬侀摼鎺ュ簱銆侀潤鎬侀摼鎺ュ簱鎴栬呴潤鎬佸鍏ュ簱[1]銆?/p>

jsconcpp 榪涜 JSON 瑙f瀽鐨勬簮鐮佹枃浠跺垎甯冨湪 include/json銆乻rc/lib_json 涓嬨傚叾瀹?jsoncpp 婧愮爜騫朵笉澶氾紝涓轟簡(jiǎn)鏂逛究浜у搧綆$悊錛屾澶勬病蹇呰灝嗗叾緙栬瘧涓哄姩鎬侀摼鎺ュ簱鎴栬呴潤鎬佸鍏ュ簱錛屾墍浠ユ垜浠夋嫨浣跨敤闈欐侀摼鎺ュ簱[2]銆?/p>

jsoncpp 宸茬粡澶勭悊鐨勫緢瀹屽杽浜?jiǎn)锛屾墍鏈夌紪璇戦夐」閮藉凡緇忛厤緗ソ錛屾墦寮makefiles/vs71/jsoncpp.sln 渚垮彲浠ュ紑濮嬬紪璇戯紙榛樿鏄嬌鐢?VS2003 緙栬瘧鍣ㄧ殑錛屾墦寮鏃剁洿鎺ユ寜鐓?VS2005 鎻愮ず杞崲鍗沖彲錛夈?/p>

鍥涖?/strong>jsoncpp 浣跨敤璇﹁В

jsoncpp 涓昏鍖呭惈涓夌綾誨瀷鐨?class錛歏alue銆丷eader銆乄riter銆俲soncpp 涓墍鏈夊璞°佺被鍚嶉兘鍦?namespace Json 涓紝鍖呭惈 json.h 鍗沖彲銆?/p>

Json::Value 鍙兘澶勭悊 ANSI 綾誨瀷鐨勫瓧絎︿覆錛屽鏋?C++ 紼嬪簭鏄敤 Unicode 緙栫爜鐨勶紝鏈濂藉姞涓涓?Adapt 綾繪潵閫傞厤銆?/p>

1銆?/strong>Value

Json::Value 鏄痡soncpp 涓渶鍩烘湰銆佹渶閲嶈鐨勭被錛岀敤浜庤〃紺哄悇縐嶇被鍨嬬殑瀵硅薄錛宩soncpp 鏀寔鐨勫璞$被鍨嬪彲瑙?Json::ValueType 鏋氫婦鍊箋?/p>

鍙涓嬫槸鐢?Json::Value 綾伙細(xì)

Json::Value json_temp; // 涓存椂瀵硅薄錛屼緵濡備笅浠g爜浣跨敤

json_temp["name"] = Json::Value("huchao");

json_temp["age"] = Json::Value(26);

Json::Value root; // 琛ㄧず鏁翠釜 json 瀵硅薄

root["key_string"] = Json::Value("value_string"); // 鏂板緩涓涓?Key錛堝悕涓猴細(xì)key_string錛夛紝璧嬩簣瀛楃涓插鹼細(xì)"value_string"銆?/p>

root["key_number"] = Json::Value(12345); // 鏂板緩涓涓?Key錛堝悕涓猴細(xì)key_number錛夛紝璧嬩簣鏁板鹼細(xì)12345銆?/p>

root["key_boolean"] = Json::Value(false); // 鏂板緩涓涓?Key錛堝悕涓猴細(xì)key_boolean錛夛紝璧嬩簣bool鍊鹼細(xì)false銆?/p>

root["key_double"] = Json::Value(12.345); // 鏂板緩涓涓?Key錛堝悕涓猴細(xì)key_double錛夛紝璧嬩簣 double 鍊鹼細(xì)12.345銆?/p>

root["key_object"] = Json_temp; // 鏂板緩涓涓?Key錛堝悕涓猴細(xì)key_object錛夛紝璧嬩簣 json::Value 瀵硅薄鍊箋?/p>

root["key_array"].append("array_string"); // 鏂板緩涓涓?Key錛堝悕涓猴細(xì)key_array錛夛紝綾誨瀷涓烘暟緇勶紝瀵圭涓涓厓绱犺祴鍊間負(fù)瀛楃涓詫細(xì)"array_string"銆?/p>

root["key_array"].append(1234); // 涓烘暟緇?key_array 璧嬪鹼紝瀵圭浜屼釜鍏冪礌璧嬪間負(fù)錛?234銆?/p>

Json::ValueType type = root.type(); // 鑾峰緱 root 鐨勭被鍨嬶紝姝ゅ涓?objectValue 綾誨瀷銆?/p>

娉細(xì)璺烠++ 涓嶅悓錛孞avaScript 鏁扮粍鍙互涓轟換鎰忕被鍨嬬殑鍊鹼紝鎵浠?jsoncpp 涔熷彲浠ャ?/p>

濡備笂鍑犱釜鐢ㄦ硶宸茬粡鍙互婊¤凍緇濆ぇ閮ㄥ垎 json 搴旂敤浜?jiǎn)锛屽綋鐒?jsoncpp 榪樻湁涓浜涘叾浠栧悓鑳斤紝姣斿璇磋緗敞閲娿佹瘮杈?json 澶у皬銆佷氦鎹?json 瀵硅薄絳夛紝閮藉緢瀹規(guī)槗浣跨敤錛屽ぇ瀹惰嚜宸卞皾璇曞惂銆?/p>

2銆?/strong>Writer

濡備笂璇翠簡(jiǎn) Json::Value 鐨勪嬌鐢ㄦ柟寮忥紝鐜板湪鍒頒簡(jiǎn)璇ユ煡鐪嬪垰鎵嶈祴鍊煎唴瀹圭殑鏃跺欎簡(jiǎn)錛屾煡鐪?json 鍐呭錛屼嬌鐢?Writer 綾誨嵆鍙?/p>

Jsoncpp 鐨?Json::Writer 綾繪槸涓涓函铏氱被錛屽茍涓嶈兘鐩存帴浣跨敤銆傚湪姝ゆ垜浠嬌鐢?Json::Writer 鐨勫瓙綾伙細(xì)Json::FastWriter銆丣son::StyledWriter銆丣son::StyledStreamWriter銆?/p>

欏懼悕鎬濅箟錛岀敤 Json::FastWriter 鏉ュ鐞?json 搴旇鏄渶蹇殑錛屼笅闈㈡垜浠潵璇曡瘯銆?/p>

Json::FastWriter fast_writer;

std::cout << fast_writer.write(root) << std::endl;

杈撳嚭緇撴灉涓猴細(xì)

{"key_array":["array_string",1234],"key_boolean":false,"key_double":12.3450,"key_number":12345,"key_object":{"age":26,"name":"huchao"},"key_string":"value_string"}

鍐嶆欏懼悕鎬濅箟錛岀敤 Json::StyledWriter 鏄牸寮忓寲鍚庣殑 json錛屼笅闈㈡垜浠潵鐪嬬湅 Json::StyledWriter 鏄庢牱鏍煎紡鍖栫殑銆?/p>

Json::StyledWriter styled_writer;

std::cout << styled_writer.write(root) << std::endl;

杈撳嚭緇撴灉涓猴細(xì)

{

"key_array" : [ "array_string", 1234 ],

"key_boolean" : false,

"key_double" : 12.3450,

"key_number" : 12345,

"key_object" : {

"age" : 26,

"name" : "huchao"

},

"key_string" : "value_string"

}

3銆?/strong>Reader

Json::Reader 鏄敤浜庤鍙栫殑錛岃鐨勭‘鍒囩偣錛屾槸鐢ㄤ簬灝嗗瓧絎︿覆杞崲涓?Json::Value 瀵硅薄鐨勶紝涓嬮潰鎴戜滑鏉ョ湅涓畝鍗曠殑渚嬪瓙銆?/p>

Json::Reader reader;

Json::Value json_object;

const char* json_document = "{\"age\" : 26,\"name\" : \"huchao\"}";

if (!reader.parse(json_document, json_object))

return 0;

std::cout << json_object["name"] << std::endl;

std::cout << json_object["age"] << std::endl;

杈撳嚭緇撴灉涓猴細(xì)

"huchao"

26

鍙錛屼笂榪頒唬鐮佸凡緇忚В鏋愬嚭浜?json 瀛楃涓層?/p>

]]>
璁篊/C++鍑芥暟闂村姩鎬佸唴瀛樼殑浼犻?http://www.shnenglu.com/idc/archive/2012/02/17/165835.html涓鍙惰崏涓鍙惰崏Fri, 17 Feb 2012 04:13:00 GMThttp://www.shnenglu.com/idc/archive/2012/02/17/165835.htmlhttp://www.shnenglu.com/idc/comments/165835.htmlhttp://www.shnenglu.com/idc/archive/2012/02/17/165835.html#Feedback11http://www.shnenglu.com/idc/comments/commentRss/165835.htmlhttp://www.shnenglu.com/idc/services/trackbacks/165835.htmlC++鐨勬牳蹇?jī)缂柦E嬬殑鏃跺欙紝浣犱細(xì)鏃犳澧冨湴涓庡唴瀛樼鐞嗘墦浜ら亾銆傝繖浜涘線寰浼?xì)鋴射汉鍙棡鎶樇偍銆傛墍浠ュ鏋滀綘鎯蟲繁鍏/C++緙栫▼錛屼綘蹇呴』闈欎笅蹇?jī)鏉ュQ屽ソ濂借嫤涓鐣?

銆銆鐜板湪鎴戜滑灝嗚璁篊/C++閲屾垜璁や負(fù)鍝竴鏈功閮芥病鏈夊畬鍏ㄨ娓呮錛屼篃鏄秹鍙?qiáng)姒傚侩娀嗚妭鏈澶氾紝璇█涓渶闅劇殑鎶鏈箣涓鐨勫姩鎬佸唴瀛樼殑浼犻掋傚茍涓斿湪杞歡寮鍙戜腑寰堝涓撲笟浜哄憳騫朵笉鑳藉啓鍑虹浉鍏崇殑鍚堟牸鐨勪唬鐮併?/p>

銆銆涓銆佸紩鍏?/p>

銆銆鐪嬩笅闈㈢殑渚嬪瓙錛岃繖鏄垜浠湪緙栧啓搴撳嚱鏁版垨鑰呴」鐩唴鐨勫叡鍚屽嚱鏁扮粡甯稿笇鏈涚殑銆?/p>

銆銆void MyFunc錛坈har *pReturn錛?size_t size錛?/p>

銆銆{………

銆銆pReturn = 錛坈har *錛塵alloc錛坰izeof錛坈har錛?* num錛夛紱………

銆銆}鎴戜滑鍙互寰堟槑鏄懼湴鐪嬪嚭浠g爜浣滆呯殑鎰忓浘錛屼粬鎯沖湪鍑芥暟璋冪敤澶勫0鏄庝竴涓寚閽堛char *pMyReturn=NULL錛涚劧鍚庤皟鐢∕yFunc澶勭悊騫惰繑鍥炰竴孌甸暱搴︿負(fù)size鐨勪竴孌靛姩鎬佸唴瀛樸?/p>

銆銆閭d箞浣滆呰兘杈懼埌棰勬湡鐨勬晥鏋滃悧錛?/p>

銆銆閭d箞鎴戝彲浠ュ憡璇変綔鑰咃紝浠栫殑紼嬪簭鍦ㄧ紪璇戞湡寰堝垢榪愬湴閫氳繃浜?jiǎn)锛屽彲鏄湪杩愯鏈熶粬鐨劷E嬪簭宕╂簝緇堟銆傚師鍥犱綍鍦紝鏄粬瑙︾姱浜?jiǎn)绯痪l熶笉鍙鏡鐘殑鏉℃錛氶敊璇湴鎿嶄綔鍐呭瓨銆?/p>

銆銆浜屻佸唴瀛樻搷浣滃強(qiáng)闂鐩稿叧鐭ヨ瘑鐐?/p>

銆銆涓轟簡(jiǎn)鑳藉交搴曡В鍐沖姩鎬佸唴瀛樹紶閫掔殑闂錛屾垜浠厛鍥為【涓涓嬪唴瀛樼鐞嗙殑鐭ヨ瘑瑕佺偣銆?/p>

銆銆錛?錛夊唴瀛樺垎閰嶆柟寮忔湁涓夌錛?/p>

銆銆浠庨潤鎬佸瓨鍌ㄥ尯鍩熷垎閰嶃傚唴瀛樺湪紼嬪簭緙栬瘧鐨勬椂鍊欏氨宸茬粡鍒嗛厤濂斤紝榪欏潡鍐呭瓨鍦ㄧ▼搴忕殑鏁翠釜榪愯鏈熼棿閮藉瓨鍦ㄣ備緥濡傚叏灞鍙橀噺錛宻tatic鍙橀噺銆?/p>

銆銆鍦ㄦ爤涓婂垱寤恒傚湪鎵ц鍑芥暟鏃訛紝鍑芥暟鍐呭眬閮ㄥ彉閲忕殑瀛樺偍鍗曞厓閮藉彲浠ュ湪鏍堜笂鍒涘緩錛屽嚱鏁版墽琛岀粨鏉熸椂榪欎簺瀛樺偍鍗曞厓鑷姩琚噴鏀俱傛爤鍐呭瓨鍒嗛厤榪愮畻鍐呯疆浜庡鐞嗗櫒鐨勬寚浠ら泦涓紝鏁堢巼寰堥珮錛屼絾鏄垎閰嶇殑鍐呭瓨瀹歸噺鏈夐檺銆?/p>

銆銆浠庡爢涓婂垎閰嶏紝浜︾О鍔ㄦ佸唴瀛樺垎閰嶃傜▼搴忓湪榪愯鐨勬椂鍊欑敤malloc鎴杗ew鐢寵浠繪剰澶氬皯鐨勫唴瀛橈紝紼嬪簭鍛樿嚜宸辮礋璐e湪浣曟椂鐢╢ree鎴杁elete閲婃斁鍐呭瓨銆傚姩鎬佸唴瀛樼殑鐢熷瓨鏈熺敱鎴戜滑鍐沖畾錛屼嬌鐢ㄩ潪甯哥伒媧匯?/p>

銆銆錛?錛夋寚閽堢殑鎿嶄綔嫻佺▼

銆銆鐢寵騫跺垵濮嬪寲鎴栬緗負(fù)絀猴細(xì)

銆銆int *pInt=NULL錛涘紑杈熺┖闂存垨鑰呬嬌鍏舵寚鍚戝璞★細(xì)

銆銆pInt=new Int錛?錛夛紱鎴栬卛nt i=3錛沺int=&i錛涚敤鎸囬拡錛堟洿紜垏鍦拌鏄搷浣滃唴瀛橈紝鍦ㄤ嬌鐢ㄤ箣鍓嶅姞if錛坧int錛?NULL錛夋垨鑰卆ssert錛坧Int錛?NULL錛夊悗鍐嶄嬌鐢紝浠ラ槻鍐呭瓨鐢寵澶辮觸鐨勬儏鍐典笅浣跨敤鎸囬拡錛夛細(xì)

銆銆if錛坧錛?NULL錛?{use pint}錛涢噴鏀句嬌鐢ㄥ畬鐨勫唴瀛?/p>

銆銆free錛坧Int錛夛紱緗寚閽堜負(fù)絀?/p>

銆銆pInt=NULL錛涳紙閬垮厤閲庢寚閽堢殑鍑虹幇錛?/p>

銆銆錛?錛夊湪鍑芥暟鐨勫弬鏁頒紶閫掍腑錛岀紪璇戝櫒鎬繪槸瑕佷負(fù)鍑芥暟鐨勬瘡涓弬鏁板埗浣滀復(fù)鏃跺壇鏈紝濡傛灉鍙傛暟涓簆鐨勮瘽錛岄偅涔堢紪璇戝櫒浼?xì)漶旂敓p鐨勫壇鏈琠p錛屼嬌_p=p錛?濡傛灉鍑芥暟浣撳唴鐨勭▼搴忎慨鏀逛簡(jiǎn)_p鐨勫唴瀹癸紝灝卞鑷村弬鏁皃鐨勫唴瀹逛綔鐩稿簲鐨勪慨鏀廣傝繖灝辨槸鎸囬拡鍙互鐢ㄤ綔杈撳嚭鍙傛暟鐨勫師鍥犮?/p>

銆銆涓夈侀棶棰樺垎鏋?/p>

銆銆鏍規(guī)嵁涓婇潰鐨勮鍒欐垜浠彲浠ュ緢瀹規(guī)槗鍒嗘瀽渚嬪瓙涓け璐ョ殑鍘熷洜銆?/p>

銆銆void MyFunc錛坈har *pReturn錛?size_t size錛?/p>

銆銆{………

銆銆pReturn = 錛坈har *錛塵alloc錛坰izeof錛坈har錛?* num錛夛紱………

銆銆} void main錛坴oid錛墈 char *pMyReturn=NULL錛汳yFunc錛坧MyReturn錛?0錛夛紱}鍦∕yFunc錛坈har *pReturn錛?size_t size錛変腑_pMyReturn鐪熷疄鍦扮敵璇峰埌浜?jiǎn)鍐呭瓨锛?pMyReturn鐢寵浜?jiǎn)鏂扮殑鍐呭瓨锛屽彧鏄妸_pMyReturn 鎵鎸囩殑鍐呭瓨鍦板潃鏀瑰彉浜?jiǎn)锛屼絾鏄痯MyReturn涓濇鏈彉銆傛墍浠ュ嚱鏁癕yFunc騫朵笉鑳借緭鍑轟換浣曚笢瑗褲備簨瀹炰笂錛屾瘡鎵ц涓嬈yFunc灝變細(xì)娉勯湶涓鍧楀唴瀛橈紝鍥犱負(fù)娌℃湁鐢╢ree閲婃斁鍐呭瓨銆?/p>

銆銆鍥涖侀棶棰樿В鍐蟲柟妗?/p>

銆銆鍑芥暟闂翠紶閫掑姩鎬佹暟鎹垜浠彲浠ユ湁涓夌瑙e喅鏂規(guī)硶銆?/p>

銆銆鏂規(guī)硶涓錛氬鏋滄垜浠槸鐢–++緙栫▼錛屾垜浠彲浠ュ緢鏂逛究鍦板埄鐢ㄥ紩鐢ㄨ繖涓妧鏈傛垜涔熸瀬鍔涙帹鑽愪綘鐢ㄥ紩鐢紝鍥犱負(fù)瀹冧細(xì)浣夸綘灝戠姱涓浜涢敊璇備互涓嬫槸涓涓緥瀛愩?/p>

銆銆void MyFunc錛坈har* &pReturn錛宻ize_t size錛墈 pReturn=錛坈har*錛塵alloc錛坰ize錛夛紱memset錛坧Return錛?x00錛宻ize錛夛紱if錛坰ize>=13錛?/p>

銆銆strcpy錛坧Return錛?Hello World錛?錛夛紱}

銆銆void main錛堬級(jí){ char *pMyReturn=NULL錛汳yFunc錛坧MyReturn錛?5錛夛紱if錛坧MyReturn錛?NULL錛?/p>

銆銆{ char *pTemp=pMyReturn錛泈hile錛?pTemp錛?''\0''錛?/p>

銆銆cout<<*pTemp++錛沺Temp=NULL錛泂trcpy錛坧MyReturn錛?AAAAAAAA"錛夛紱free錛坧MyReturn錛夛紱pMyReturn=NULL錛泒鏂規(guī)硶浜岋細(xì)鍒╃敤浜岀駭鎸囬拡

銆銆void MyFunc 錛坈har ** pReturn錛?size_t size錛?/p>

銆銆{ * pReturn = 錛坈har *錛塵alloc錛坰ize錛夛紱} void main錛坴oid錛?/p>

銆銆{ char * pMyReturn = NULL錛汳yFunc 錛?amp;pMyReturn錛?100錛夛紱// 娉ㄦ剰鍙傛暟鏄?& pMyReturn if錛坧MyReturn錛?NULL錛墈 strcpy錛坧MyReturn錛?"hello"錛夛紱cout<< pMyReturn << endl錛沠ree錛坧MyReturn錛夛紱pMyReturn=NULL錛泒}涓轟粈涔堜簩綰ф寚閽堝氨鍙互浜?jiǎn)銆傚師鍥犻氳繃鍑芥暟浼犻掕鍒欏彲浠ュ緢瀹規(guī)槗鍦板垎鏋愬嚭鏉ャ傛垜浠皢& pMyReturn浼犻掍簡(jiǎn)榪涘幓錛屽氨鏄皢鍙岄噸鎸囬拡鐨勫唴瀹逛紶閫掑埌浜?jiǎn)鍑芥曨C腑銆傚嚱鏁拌繃紼嬪埄鐢ㄦ敼鍙樻寚閽堢殑鍐呭錛岃繖鏍穚MyReturn寰堟槑鏄炬寚鍚戜簡(jiǎn)寮杈熺殑鍐呭瓨 .

銆銆鏂規(guī)硶涓夛細(xì)鐢ㄥ嚱鏁拌繑鍥炲兼潵浼犻掑姩鎬佸唴瀛?/p>

銆銆char * MyFunc 錛坴oid錛?/p>

銆銆{ char *p =new char[20]錛沵emset錛坧錛?x00錛宻izeof錛坧錛夛級(jí)錛況eturn p錛泒 void main錛坴oid錛?/p>

銆銆{ char *str = NULL錛泂tr = MyFunc錛堬級(jí)錛沬f錛坰tr錛?NULL錛?/p>

銆銆{ strcpy錛坰tr錛?Hello錛宐aby"錛夛紱cout<< str << endl錛沠ree錛坰tr錛夛紱str=NULL錛泒璇鋒敞鎰忕殑鏄嚱鏁板啓鎴愯繖鏍風(fēng)殑璇濓紝浣犳槸涓嶈兘榪斿洖浠涔堝姩鎬佸唴瀛樼殑錛屽洜涓簆鎸囧悜鐨勬槸瀛楃涓插父閲忋傚唴瀛樺湪浣嶄簬闈欐佸瓨鍌ㄥ尯涓婂垎閰嶏紝浣犳棤娉曟敼鍙樸傦紙浣犳兂瑕佸緱鍒板姩鎬佸唴瀛樻垜浠竴瀹氳鐪嬪埌malloc鎴栬卬ew錛夈?/p>

銆銆char * MyFunc 錛坴oid錛?/p>

銆銆{ char *p =“Hello World”

銆銆return p錛泒緇撴潫璇?/p>

銆銆鎿嶄綔鍐呭瓨鏄疌/C++涓涓毦鐐癸紝鎴戜滑浣滀負(fù)涓撲笟鐨勮蔣浠跺紑鍙戜漢鍛樸傚簲璇ユ繁鍏ョ悊瑙e茍鑳界伒媧誨湴鎺屾彙鎸囬拡鍜屽唴瀛樼殑鎿嶄綔銆?/p>

]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
      <noscript id="pjuwb"></noscript>
            <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
              <dd id="pjuwb"></dd>
              <abbr id="pjuwb"></abbr>
              亚洲三级影院| 亚洲国产高清在线观看视频| 亚洲福利久久| 欧美久久精品午夜青青大伊人| 久久久人成影片一区二区三区观看| 欧美视频在线观看| 99热这里只有精品8| 亚洲精品裸体| 欧美国产视频在线观看| 亚洲国产影院| 一本大道久久a久久精二百| 欧美日韩国产在线播放| 亚洲免费网站| 久久久精品五月天| 在线观看亚洲精品视频| 欧美77777| 99精品热视频| 亚洲清纯自拍| 亚洲国产精品999| 欧美电影免费网站| 99精品免费| 国产日韩精品视频一区二区三区| 欧美影院在线播放| 欧美国产亚洲视频| 午夜伦理片一区| 海角社区69精品视频| 欧美大胆成人| 亚洲欧美激情诱惑| 亚洲欧美日韩国产综合精品二区| 欧美成人一区二区在线| 裸体素人女欧美日韩| 日韩一区二区福利| 日韩一级视频免费观看在线| 99精品欧美一区二区三区综合在线| 亚洲日本成人网| 日韩午夜电影在线观看| 一区二区三区高清在线观看| 黄网站免费久久| 国产精品扒开腿做爽爽爽视频 | 樱桃成人精品视频在线播放| 国产视频在线观看一区二区| 欧美大片免费看| 欧美激情精品久久久久久黑人 | 国产精品一香蕉国产线看观看| 久久久免费精品视频| 日韩五码在线| 欧美国产高清| 亚洲人成网站999久久久综合| 日韩视频免费| 亚洲免费人成在线视频观看| 久久精品官网| 亚洲欧美一区二区三区久久| 午夜欧美大尺度福利影院在线看 | 国产精品黄色| 久久久免费精品视频| 免费在线看成人av| 欧美日韩第一区| 国产欧美一区二区精品婷婷| 在线精品高清中文字幕| 国产一区二三区| 国产精品永久入口久久久| 狠狠色综合一区二区| 亚洲精品久久久久| 亚洲制服av| 国产精品一区=区| 国产亚洲欧美日韩美女| 国产精品成人一区二区艾草| 国产日韩欧美a| 亚洲人精品午夜在线观看| 亚洲成人资源| 一区电影在线观看| 久久成人亚洲| 久久精品国产一区二区电影| 亚洲影院在线观看| 老色鬼精品视频在线观看播放| 亚洲高清资源综合久久精品| 欧美二区不卡| 亚洲午夜免费福利视频| 亚洲麻豆av| 99精品热6080yy久久 | 欧美黑人国产人伦爽爽爽| 国产精品久久久久久久久久免费看| 欧美日韩不卡一区| 国产亚洲一区二区三区| 日韩一区二区久久| 久久久久高清| 一二美女精品欧洲| 亚洲视频二区| 欧美一区二区三区在线视频| 午夜视频在线观看一区二区三区| 欧美高清一区| 黄色成人在线网站| 亚洲欧美一区二区在线观看| 亚洲国产一二三| 欧美在线观看www| 国产精品久久久一区二区| 亚洲国产视频直播| 一区二区三区av| 欧美成人高清视频| 亚洲国产精品久久久| 欧美亚洲一区二区在线| 亚洲毛片一区| 久久久久久夜| 国产精品美女久久| 亚洲免费电影在线观看| 久久色在线观看| 亚洲一级在线| 欧美日韩一区二区三区四区五区| 欧美午夜精品久久久久久超碰| 亚洲国产91精品在线观看| 久久久欧美精品| 亚洲免费在线播放| 国产精品美女久久久久久久| 亚洲一级在线观看| 久久久蜜桃精品| 香蕉乱码成人久久天堂爱免费 | 免费成人av| 欧美午夜精品久久久久久浪潮 | 亚洲精选视频在线| 久久频这里精品99香蕉| 免费亚洲电影在线观看| 影音先锋国产精品| 老司机免费视频一区二区| 欧美一区国产一区| 国产视频精品va久久久久久| 午夜免费电影一区在线观看| 亚洲一区日韩在线| 美国三级日本三级久久99| 国产精品chinese| 亚洲无线视频| 宅男精品导航| 国产乱子伦一区二区三区国色天香 | 亚洲精品在线免费| 欧美伦理影院| 亚洲综合视频网| 亚洲欧美国产精品桃花| 国产人成一区二区三区影院| 久久久亚洲午夜电影| 久久米奇亚洲| 亚洲精品一区中文| 日韩午夜精品视频| 国产精品国产三级国产aⅴ无密码| 亚洲欧美影音先锋| 欧美中文日韩| 亚洲精品免费看| 在线亚洲一区| 国产一区二区三区久久精品| 免费精品视频| 欧美日本国产| 久久国产精品一区二区三区| 久久噜噜噜精品国产亚洲综合| 亚洲欧洲一区二区三区| 夜夜嗨av色综合久久久综合网| 国产目拍亚洲精品99久久精品| 久久人人97超碰精品888| 免费成人av在线| 亚洲综合色噜噜狠狠| 久久精品国产第一区二区三区最新章节 | 国产精品红桃| 巨乳诱惑日韩免费av| 欧美精品在线观看| 午夜伦理片一区| 老司机午夜精品视频在线观看| 狠狠入ady亚洲精品| 亚洲国产高清一区| 国产精品欧美日韩久久| 亚洲一区二区少妇| 欧美一区在线直播| 99综合精品| 欧美专区在线观看| 一本色道久久88综合日韩精品| 亚洲欧美日韩国产中文在线| 亚洲国产精选| 午夜精品在线视频| 亚洲精选中文字幕| 欧美一区二区在线| 中文精品一区二区三区| 一区二区不卡在线视频 午夜欧美不卡在 | 正在播放亚洲一区| 久久激情综合| 亚洲男人av电影| 亚洲女人小视频在线观看| 亚洲级视频在线观看免费1级| 在线中文字幕一区| 亚洲欧洲午夜| 欧美一区2区视频在线观看| 99视频精品免费观看| 久久精选视频| 亚洲国产一区视频| 午夜久久黄色| 亚洲男女自偷自拍图片另类| 免费高清在线视频一区·| 久久精品男女| 国产精品久久久99| 亚洲精品五月天| 亚洲国产欧美精品| 欧美一区免费视频| 午夜精品美女自拍福到在线| 欧美日韩福利视频| 亚洲激情啪啪|