[C語言面試編程題]java面試編程題_第1頁
[C語言面試編程題]java面試編程題_第2頁
[C語言面試編程題]java面試編程題_第3頁
[C語言面試編程題]java面試編程題_第4頁
免費(fèi)預(yù)覽已結(jié)束,剩余1頁可下載查看

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、c語言面試編程題java面試編程題 在c語言中,輸入和輸出是經(jīng)由標(biāo)準(zhǔn)庫中的一組函數(shù)來實(shí)現(xiàn)的。在ansi/iso c中,這些函數(shù)被定義在頭文件;中。下面就由為大家介紹一下c語言面試編程題的文章,歡迎閱讀。 c語言面試編程題篇1 考查的是結(jié)構(gòu)體和數(shù)組的內(nèi)存布局狀況。 #include #include typedef struct array1 int id; struct array1* next; a; typedef struct array2 int id; int a; int b; int c; * b; int main() a s115; a* s2; b s3; for(int

2、i=0;i10;i+) s1i.id=i+64; s2=s1+3; s3=(b)s2; printf(%d/n,s3-b); return 0; c語言面試編程題篇2 從字符串?dāng)?shù)組和指針字符串在內(nèi)存中的安排狀況考查指針的用法。 #include #include #include char *getmemory(char *p) p = (char *)malloc(100); return p; /當(dāng)調(diào)用此函數(shù)時(shí),會(huì)在棧里安排一個(gè)空間存儲(chǔ)p, p指向堆當(dāng)中的一塊內(nèi)存區(qū),當(dāng)函數(shù)調(diào)用結(jié)束后,若函數(shù)沒有返回值, /系統(tǒng)自動(dòng)釋放棧中的p void test(void) char *str = nul

3、l; str=getmemory(str); strcpy(str, test); printf(%s/n,str); char *getmemory1(void) char *p = test1; return p; /若換成char p=hello world; 就會(huì)在函數(shù)調(diào)用結(jié)束后,釋放掉為test1的拷貝安排的空間,返回的p只是一個(gè)野指針 void test1() char *str = ; str=getmemory1(); printf(%s/n,str); /str=getmemory(); void getmemory2(char *p, int num) *p = (char

4、 *)malloc(num); /當(dāng)調(diào)用此函數(shù)時(shí),會(huì)在棧里安排一個(gè)空間存儲(chǔ)p, p指向棧中的一變量str,在此函數(shù)中為str在堆當(dāng)中安排了一段內(nèi)存空間 /函數(shù)調(diào)用結(jié)束后,會(huì)釋放p, 但str所在的函數(shù)test2還沒運(yùn)行完,所以str此時(shí)還在棧里. void test2(void) char *str = null; getmemory2(str, 100); strcpy(str, hello); printf(%s/n,str); void test3(void) char *str=(char *)malloc(100); strcpy(str, hello);/此時(shí)的str指向的是拷貝到

5、棧里的hello,所以當(dāng)釋放掉str指向的堆空間時(shí),str指向的棧里的值還是不變 free(str); if(str != null) strcpy(str, world); printf(%s/n,str); int main() test(); test1(); test2(); test3(); c語言面試編程題篇3 c語言中sizeof的用法 void fun(char s10) printf(%s/n,s); printf(%d/n,sizeof(s);/引用的大小 int main() char str=sasdasdes; printf(%d/n,sizeof(str);/字符串?dāng)?shù)組的大小10(包含了字符/0) printf(%d/n,strlen(str);/字符串的長度9 char *p=str; printf(%d/n,sizeof(p);/指針的大小4 printf(%d/n,strlen(p);/字符串的長度9 fun(str); void *h=malloc(100); char ss100=abcd; printf(%d/

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論