freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

c語言終極面試寶典c語言面試必備-資料下載頁

2025-03-24 01:33本頁面
  

【正文】 int i: 8。 int j: 4。 int a: 3。 double b。}。struct s2{ int i: 8。 int j: 4。 double b。 int a:3。}。printf(sizeof(s1)= %d\n, sizeof(s1))。printf(sizeof(s2)= %d\n, sizeof(s2))。result: 16, 24第一個struct s1{ int i: 8。 int j: 4。 int a: 3。 double b。}。理論上是這樣的,首先是i在相對0的位置,占8位一個字節(jié),然后,j就在相對一個字節(jié)的位置,由于一個位置的字節(jié)數(shù)是4位的倍數(shù),因此不用對齊,就放在那里了,然后是a,要在3位的倍數(shù)關系的位置上,因此要移一位,在15位的位置上放下,目前總共是18位,折算過來是2字節(jié)2位的樣子,由于double是8字節(jié)的,因此要在相對0要是8個字節(jié)的位置上放下,因此從18位開始到8個字節(jié)之間的位置被忽略,直接放在8字節(jié)的位置了,因此,總共是16字節(jié)。第二個最后會對照是不是結(jié)構(gòu)體內(nèi)最大數(shù)據(jù)的倍數(shù),不是的話,會補成是最大數(shù)據(jù)的倍數(shù)3在對齊為4的情況下struct BBB{ long num; char *name。 short int data。 char ha。 short ba[5]。}*p。p=0x1000000。p+0x200=____。(Ulong)p+0x200=____。(char*)p+0x200=____。希望各位達人給出答案和原因,謝謝拉解答:假設在32位CPU上,sizeof(long) = 4 bytessizeof(char *) = 4 bytessizeof(short int) = sizeof(short) = 2 bytessizeof(char) = 1 bytes由于是4字節(jié)對齊,sizeof(struct BBB) = sizeof(*p) = 4 + 4 + 2 + 1 + 1/*補齊*/ + 2*5 + 2/*補齊*/ = 24 bytes (經(jīng)DevC++驗證)p=0x1000000。p+0x200=____。 = 0x1000000 + 0x200*24(Ulong)p+0x200=____。 = 0x1000000 + 0x200(char*)p+0x200=____。 = 0x1000000 + 0x200*43找錯Void test1(){char string[10]。char* str1=0123456789。strcpy(string, str1)。// 溢出,應該包括一個存放39。\039。的字符string[11]}Void test2(){char string[10], str1[10]。for(I=0。 I10。I++){str1[i] =39。a39。}strcpy(string, str1)。// I,i沒有聲明。}Void test3(char* str1){char string[10]。if(strlen(str1)=10)// 改成10,字符溢出,將strlen改為sizeof也可以{strcpy(string, str1)。}}3寫出輸出結(jié)果void g(int**)。int main(){int line[10],i。int *p=line。 //p是地址的地址for (i=0。i10。i++){*p=i。g(amp。p)。//數(shù)組對應的值加1}for(i=0。i10。i++)printf(%d\n,line[i])。return 0。}void g(int**p){(**p)++。(*p)++。// 無效}輸出:12 3 4 5 6 7 8 9 103寫出程序運行結(jié)果int sum(int a){auto int c=0。static int b=3。c+=1。b+=2。return(a+b+c)。}void main(){int I。int a=2。for(I=0。I5。I++){printf(%d, sum(a))。}}// static會保存上次結(jié)果,記住這一點,剩下的自己寫輸出:8,10,12,14,16,3評價代碼int func(int a){int b。switch(a){case 1: 30。case 2: 20。case 3: 16。default: 0}return b。}則func(1)=?// b定義后就沒有賦值int a[3]。a[0]=0。 a[1]=1。 a[2]=2。int *p, *q。p=a。q=amp。a[2]。則a[qp]=a[2]解釋:指針一次移動一個int但計數(shù)為13請問一下程序?qū)⑤敵鍪裁唇Y(jié)果?char *RetMenory(void){ char p[] = “hellow world”。 return p。}void Test(void){ char *str = NULL。 str = RetMemory()。 printf(str)。}RetMenory執(zhí)行完畢,p資源被回收,指向未知地址。返回地址,str的內(nèi)容應是不可預測的, 打印的應該是str的地址寫出輸出結(jié)果typedef struct { int a:2。 int b:2。 int c:1。 }test。 test t。 = 1。 = 3。 = 1。 printf(%d,)。 printf(%d,)。 printf(%d,)。,輸出就是1,輸出就是-1,輸出也是13個都是有符號數(shù)int嘛。這是位擴展問題 01111編譯器進行符號擴展4對下面程序進行分析void test2() { char string[10], str1[10]。 int i。 for(i=0。 i10。 i++) { str1[i] = 39。a39。 } strcpy( string, str1 )。 } 解答:如果面試者指出字符數(shù)組str1不能在數(shù)組內(nèi)結(jié)束可以給3分;如果面試者指出strcpy(string, str1)調(diào)用使得從str1內(nèi)存起復制到string內(nèi)存起所復制的字節(jié)數(shù)具有不確定性可以給7分,在此基礎上指出庫函數(shù)strcpy工作方式的給10分;str1不能在數(shù)組內(nèi)結(jié)束:因為str1的存儲為:{a,a,a,a,a,a,a,a,a,a},沒有39。\039。(字符串結(jié)束符),所以不能結(jié)束strcpy( char *s1,char *s2)他的工作原理是,掃描s2指向的內(nèi)存,逐個字符付到s1所指向的內(nèi)存,直到碰到39。\039。,因為str1結(jié)尾沒有39。\039。,所以具有不確定性,不知道他后面還會付什么東東。正確應如下void test2() { char string[10], str1[10]。 int i。 for(i=0。 i9。 i++) { str1[i] = 39。a39。+i。 //把abcdefghi賦值給字符數(shù)組 } str[i]=39。\039。//加上結(jié)束符 strcpy( string, str1 )。 }4分析:int arr[] = {6,7,8,9,10}。int *ptr = arr。*(ptr++)+=123。printf(“ %d %d ”, *ptr, *(++ptr))。輸出:8 8過程:對于*(ptr++)+=123。先做加法6+123,然后++,指針指向7;對于printf(“ %d %d ”, *ptr, *(++ptr))。從后往前執(zhí)行,指針先++,指向8,然后輸出8,緊接著再輸出84分析下面的代碼:char *a = hello。char *b = hello。if(a= =b)printf(YES)。elseprintf(NO)。這個簡單的面試題目,我選輸出 no(對比的應該是指針地址吧),可在VC是YES 在C是NOlz的呢,是一個常量字符串。位于靜態(tài)存儲區(qū),它在程序生命期內(nèi)恒定不變。如果編譯器優(yōu)化的話,會有可能a和b同時指向同一個hello的。則地址相同。如果編譯器沒有優(yōu)化,那么就是兩個不同的地址,則不同4寫出輸出結(jié)果include void foo(int m, int n){ printf(m=%d, n=%d\n, m, n)。}int main(){ int b = 3。 foo(b+=3, ++b)。 printf(b=%d\n, b)。return 0。}輸出:m=7,n=4,b=7()這種方式和編譯器中得函數(shù)調(diào)用關系相關即先后入棧順序。不過不同編譯器得處理不同。也是因為C標準中對這種方式說明為未定義,所以各個編譯器廠商都有自己得理解,所以最后產(chǎn)生得結(jié)果完全不同。因為這樣,所以遇見這種函數(shù),我們首先要考慮我們得編譯器會如何處理這樣得函數(shù),其次看函數(shù)得調(diào)用方式,不同得調(diào)用方式,可能產(chǎn)生不同得結(jié)果。最后是看編譯器優(yōu)化。4找出錯誤include main(void){ char *src=hello,world。 char *dest=NULL。 dest=(char *)malloc(strlen(src))。 int len=strlen(str)。 char *d=dest。 char *s=src[len]。 while(len!=0) d++=s。 printf(%s,dest)。}找出錯誤!!include include include main(void){ char *src=hello,world。 char *dest=NULL。 dest=(char *)malloc(sizeof(char)*(strlen(src)+1))。 int len=strlen(src)。 char *d=dest。 char *s=src+len1。 while(len!=0) *d++=*s。*d=39。\039。 printf(%s,dest)。}第三部分:編程題(例如):123456:563412include include int main(void){ int MAX = 10。int *a = (int *)malloc(MAX * sizeof(int))。int *b。 FILE *fp1。FILE *fp2。fp1 = fopen(,r)。if(fp1 == NULL){printf(error1)。 exit(1)。} fp2 = fopen(,w)。if(fp2 == NULL){printf(error2)。 exit(1)。}int i = 0。 int j = 0。while(fscanf(fp1,%d,amp。a[i]) != EOF){i++。j++。if(i = MAX){MAX = 2 * MAX。b = (int*)realloc(a,MAX * sizeof(int))。if(b == NULL){printf(error3)。exit(1)。}a = b。}}for(。j = 0。) fprintf(fp2,%d\n,a[j])。fclose(fp1)。fclose(fp2)。return 0。}輸出和為一個給定整數(shù)的所有組合例如n=55=1+4;5=2+3(相加的數(shù)不能重復)則輸出1,4;2,3。include int main(void){unsigned long int i,j,k。printf(please input the number\n)。scanf(%d,amp。i)。 if( i % 2 == 0) j = i / 2。elsej = i / 2 + 1。printf(The result is \n)。 for(k = 0。 k j。 k++) printf(%d = %d + %d\n,i,k,i k)。return 0。}include void main()
點擊復制文檔內(nèi)容
環(huán)評公示相關推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1