久久综合丝袜日本网手机版,日韩欧美中文字幕在线三区,亚洲精品国产品国语在线,极品在线观看视频婷婷

      • 華為全套面試題基礎(chǔ)版

        時(shí)間:2022-07-11 15:02:56 面試 我要投稿
        • 相關(guān)推薦

        華為全套面試題(基礎(chǔ)版)

        華為全套面試題(基礎(chǔ)版)

        華為全套面試題(基礎(chǔ)版)

        1什么是預(yù)編譯,何時(shí)需要預(yù)編譯:

        答案:1總是使用不經(jīng)常改動(dòng)的大型代碼體

        2程序由多個(gè)模塊組成,所有模塊都使用一組標(biāo)準(zhǔn)的包含文件和相同的編譯選項(xiàng)在這種情況下,可以將所有包含文件預(yù)編譯為一個(gè)預(yù)編譯頭

        2char * const p

        char const * p

        const char *p

        上述三個(gè)有什么區(qū)別?

        答案:

        char * const p; //常量指針,p的值不可以修改

        char const * p;//指向常量的指針,指向的常量值不可以改

        const char *p; //和char const *p

        3char str1[] = "abc";

        char str2[] = "abc";

        const char str3[] = "abc";

        const char str4[] = "abc";

        const char *str5 = "abc";

        const char *str6 = "abc";

        char *str7 = "abc";

        char *str8 = "abc";

        cout << ( str1 == str2 ) << endl;

        cout << ( str3 == str4 ) << endl;

        cout << ( str5 == str6 ) << endl;

        cout << ( str7 == str8 ) << endl;

        結(jié)果是:0 0 1 1

        str1,str2,str3,str4是數(shù)組變量,它們有各自的內(nèi)存空間;

        而str5,str6,str7,str8是指針,它們指向相同的常量區(qū)域

        4以下代碼中的兩個(gè)sizeof用法有問(wèn)題嗎?[C易]

        void UpperCase( char str[] ) // 將 str 中的小寫字母轉(zhuǎn)換成大寫字母

        {

        for( size_t i=0; i

        if( a<=str[i] && str[i]<=z )

        str[i] -= (a-A );

        }

        char str[] = "aBcDe";

        cout << "str字符長(zhǎng)度為: " << sizeof(str)/sizeof(str[0]) << endl;

        UpperCase( str );

        cout << str << endl;

        答案:函數(shù)內(nèi)的sizeof有問(wèn)題根據(jù)語(yǔ)法,sizeof如用于數(shù)組,只能測(cè)出靜態(tài)數(shù)組的大小,無(wú)法檢測(cè)動(dòng)態(tài)分配的或外部數(shù)組大小函數(shù)外的str是一個(gè)靜態(tài)定義的數(shù)組,因此其大小為6,因?yàn)檫有\(zhòng)