LinuxC筆試題(ti)(北(bei)京質數科技)
時間:2018-08-03 來源:未知
下面(mian)是我在北(bei)京質數科技有限公司面(mian)試時遇(yu)到的一(yi)些(xie)linuxC面(mian)試題,這(zhe)些(xie)面(mian)試題我總(zong)結出一(yi)個問題就(jiu)是平時大家要多寫代碼(ma),把每天(tian)的作業做完,筆試應該(gai)沒什么(me)問題;切記勤于練(lian)習最重要,希望這(zhe)些(xie)面(mian)試題可以幫到你,而且這(zhe)些(xie)也是在企業面(mian)試中最常見的,一(yi)起來(lai)看(kan)看(kan)吧
1. 求結構體的(de)長(chang)度 32bit平(ping)臺
a) struct A{
int a;
char b;
short c;
int d;
};
b) struct B{
int a;
char b;
int c;
short d;
};
c) struct C{
char a;
int b;
int c;
short d;
};
A a;
B b;
C c;
Sizeof(a) = ?;
Sizeof(b) = ?;
Sizeof(c) = ?;
注:考察(cha)結構體字(zi)節(jie)對齊。
2. signal函數的(de)定(ding)義?列(lie)舉常(chang)用的(de)信號及處理方式(shi)。
3.
注(zhu):考察對信號的掌(zhang)握和使(shi)(shi)(shi)用;面試會問到(dao)是(shi)否(fou)使(shi)(shi)(shi)用過(guo)信號,在什么(me)情(qing)況下使(shi)(shi)(shi)用信號。
4. GDB的用法
a) GCC編譯時,加______參數,用于生成可(ke)GDB調試的可(ke)執行文(wen)件;
b) 添加斷點______;
c) 從一個函數中返回______;
……
注:考察GDB用法,平時多(duo)用,面試(shi)的時候稍微回憶一(yi)下就可以了。
5. for循環(huan)的結果(guo)
6.
注:這個很easy, 就不寫(xie)了。
7. 實現兩個(ge)int變量(liang)的值的交換,要求不使用臨時變量(liang)。
int swap (int *a, int *b)
{
*a = (*a) ^ (*b);
*b = (*a) ^ (*b);
*a = (*a) ^ (*b);
}
注:考察位操作 — 異(yi)或,如果(guo)以(yi)前(qian)沒(mei)見過(guo)類似(si)的(de)題,估計筆試的(de)時(shi)候很難想出來。
8. POSIX線(xian)程基本概念(nian)的三個知識點(dian)
a) 對線程的操作
pthread_create();
pthread_exit();
pthread_cancel();
pthread_join();
b) 對(dui)互斥量的操作
pthread_mutex_init();
pthread_mutex_destroy();
pthread_mutex_lock();
pthread_mutex_trylock();
pthread_mutex_unlock();
c) 對條件變量(liang)的操作
pthread_cond_init();
pthread_cond_destroy();
pthread_cond_wait();
pthread_cond_single();
pthread_cond_broadcast();
注:考察對POSIX線(xian)程的(de)(de)掌握,技術(shu)面試的(de)(de)時候(hou)會(hui)問(wen)到很多關于(yu)這方面的(de)(de)問(wen)題。
9. 用偽(wei)代(dai)碼實現一個基于TCP協議(yi)的Client/Server模型
a) Client
int sfd;
//get socket descriptor;
sfd = socket(...);
//bind address for socket descriptor;
bind(sfd,…);
//sned or receive data;
sendto(sfd,…);
recvfrom(sfd,…);
//close socket descriptor;
close(sfd);
b) Server
int sfd;
//get socket descriptor;
sfd = socket();
//bind address for socket descriptor;
bind(sfd,…);
//send or receive data;
recvfrom();
sendto(sfd,…);
//close socket descriptor;
close(sfd);
注:考(kao)察對SOCKET編程的掌握,如(ru)果簡歷上面寫了類似的項(xiang)目經驗(yan),技術面試會詳(xiang)細的問你這方面的知識(甚至具(ju)體(ti)到很多細節)。
10. 下面(mian)一條(tiao)語句的意思:
int(*s[10])(int);
定(ding)義(yi)了一(yi)個指針(zhen)數組,元(yuan)素的類型為函數指針(zhen),指向的函數是這樣(yang)的:函數返回值為int,函數只有一(yi)個參(can)數為int。
注(zhu):這(zhe)個就看(kan)你平時寫程(cheng)序(xu)的多少了。如果以(yi)前沒見過或沒用(yong)過,你就慘了。

