企(qi)業常(chang)見的嵌(qian)入式面試題,讓(rang)你不再擔(dan)心(xin)面試
時間:2018-08-03 來源(yuan):未知
經過我(wo)面(mian)試了多家公司,總結了下(xia)面(mian)在筆(bi)試中非(fei)常(chang)常(chang)見的幾(ji)個題,而且(qie)這些都是(shi)我(wo)在面(mian)試中基本每次筆(bi)試都會出現的問(wen)題,希望對后面(mian)的求(qiu)職者是(shi)有用(yong)的,可以都收藏下(xia)來(lai)哦
1.Static的作用
2.字符串(chuan)拷貝函數,字符串(chuan)翻轉(zhuan)
3.Sizeof相(xiang)關的一些題
4、有關內存的思考題(ti)
2001 Page 95 of 103 高質量(liang) C++/C 編程指南(nan),v 1.0 void GetMemory(char *p)
{
p = (char *)malloc(100);
}
void Test(void)
{
char *str = NULL;
GetMemory(str);
strcpy(str, "hello world");
printf(str);
}
請問運行Test函數會有什么樣的結果?
答: char *GetMemory(void)
{
char p[] = "hello world";
return p;
}
void Test(void)
{
char *str = NULL;
str = GetMemory();
printf(str);
}
請問運行Test函數(shu)會(hui)有什么樣的結(jie)果?
答:
Void GetMemory2(char **p, int num)
{
*p = (char *)malloc(num);
}
void Test(void)
{
char **str = NULL;
GetMemory(str, 100);
strcpy(str, "hello");
printf(str);
}
請(qing)問(wen)運行Test函數會有什么(me)樣的結(jie)果?
答: void Test(void)
{
char *str = (char *) malloc(100);
strcpy(str, “hello”);
free(str);
if(str != NULL)
{
strcpy(str, “world”);
printf(str);
}
}
請問運行Test函數會有什么樣的結果?
答:
5.樹的(de)先(xian)序后序
有些公司還考智力題,不過很少,例(li)如
你讓某些人為(wei)(wei)你工作(zuo)了七天(tian),你要用一根金條作(zuo)為(wei)(wei)報酬。這(zhe)根金條要被分(fen)成七塊。你必須在每(mei)天(tian)的活(huo)干完后交給他們一塊。如果你只能將這(zhe)根金條切割兩次(ci),你怎樣給這(zhe)些工人分(fen);
主要還是程序員(yuan)寶典上(shang)的(de),考(kao)的(de)非常多,書上(shang)大部分的(de)題還是看看,至少有(you)個印象。

