當(dāng)前位置:首頁 > 嵌入式培訓(xùn) > 嵌入式招聘 > 嵌入式面試題 > LinuxC筆試題(北京質(zhì)數(shù)科技)
LinuxC筆試題(北京質(zhì)數(shù)科技)
時(shí)間:2018-08-03 來源:未知
下面是我在北京質(zhì)數(shù)科技有限公司面試時(shí)遇到的一些linuxC面試題,這些面試題我總結(jié)出一個(gè)問題就是平時(shí)大家要多寫代碼,把每天的作業(yè)做完,筆試應(yīng)該沒什么問題;切記勤于練習(xí)最重要,希望這些面試題可以幫到你,而且這些也是在企業(yè)面試中最常見的,一起來看看吧
1. 求結(jié)構(gòu)體的長(zhǎng)度 32bit平臺(tái)
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) = ?;
注:考察結(jié)構(gòu)體字節(jié)對(duì)齊。
2. signal函數(shù)的定義?列舉常用的信號(hào)及處理方式。
3.
注:考察對(duì)信號(hào)的掌握和使用;面試會(huì)問到是否使用過信號(hào),在什么情況下使用信號(hào)。
4. GDB的用法
a) GCC編譯時(shí),加______參數(shù),用于生成可GDB調(diào)試的可執(zhí)行文件;
b) 添加斷點(diǎn)______;
c) 從一個(gè)函數(shù)中返回______;
……
注:考察GDB用法,平時(shí)多用,面試的時(shí)候稍微回憶一下就可以了。
5. for循環(huán)的結(jié)果
6.
注:這個(gè)很easy, 就不寫了。
7. 實(shí)現(xiàn)兩個(gè)int變量的值的交換,要求不使用臨時(shí)變量。
int swap (int *a, int *b)
{
*a = (*a) ^ (*b);
*b = (*a) ^ (*b);
*a = (*a) ^ (*b);
}
注:考察位操作 — 異或,如果以前沒見過類似的題,估計(jì)筆試的時(shí)候很難想出來。
8. POSIX線程基本概念的三個(gè)知識(shí)點(diǎn)
a) 對(duì)線程的操作
pthread_create();
pthread_exit();
pthread_cancel();
pthread_join();
b) 對(duì)互斥量的操作
pthread_mutex_init();
pthread_mutex_destroy();
pthread_mutex_lock();
pthread_mutex_trylock();
pthread_mutex_unlock();
c) 對(duì)條件變量的操作
pthread_cond_init();
pthread_cond_destroy();
pthread_cond_wait();
pthread_cond_single();
pthread_cond_broadcast();
注:考察對(duì)POSIX線程的掌握,技術(shù)面試的時(shí)候會(huì)問到很多關(guān)于這方面的問題。
9. 用偽代碼實(shí)現(xiàn)一個(gè)基于TCP協(xié)議的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);
注:考察對(duì)SOCKET編程的掌握,如果簡(jiǎn)歷上面寫了類似的項(xiàng)目經(jīng)驗(yàn),技術(shù)面試會(huì)詳細(xì)的問你這方面的知識(shí)(甚至具體到很多細(xì)節(jié))。
10. 下面一條語句的意思:
int(*s[10])(int);
定義了一個(gè)指針數(shù)組,元素的類型為函數(shù)指針,指向的函數(shù)是這樣的:函數(shù)返回值為int,函數(shù)只有一個(gè)參數(shù)為int。
注:這個(gè)就看你平時(shí)寫程序的多少了。如果以前沒見過或沒用過,你就慘了。

