c語言常見筆試題總結

時間:2023-04-05 02:30:49 筆試題目 我要投稿
  • 相關推薦

c語言常見筆試題總結

  【1 使用宏】

c語言常見筆試題總結

  1.1

  #ifdef NDEBUG

  #define TRACE(S) S

  #else

  #define TRACE(S) printf(“%s;\n”, #S); S

  #endif

  問:以上TRACE()宏的作用是什么?

  1.2 #error的作用?

  1.3 定義一個宏,求出給定數組中的元素的個數

  #define NELEMENTS(array) ??

  1.4 定義一個宏,求出給定結構中給定成員的偏移量

  #define OFFSET(structure, member) ??

  【2 數據聲明和定義】

  給定以下類型的變量a的定義式:

  a) An integer

  b) A pointer to an integer

  c) A pointer to a pointer to an integer

  d) An array of 10 integers

  e) An array of 10 pointers to integers

  f) A pointer to an array of 10 integers

  g) A pointer to a function that takes an integer as an argument and returns an integer

  h) An array of ten pointers to functions that take an integer argument and return an integer

  【3 復雜類型(1)】

  有如下表達式:

  char (*(*x())[])();

  請用文字描述x是什么。

  【4 復雜類型(2)】

  jmp_buf的定義:

  typedef struct _jmp_buf

  {

  REG_SET reg;

  int extra[3];

  } jmp_buf[1];

  setjmp函數的原型:

  extern int setjmp (jmp_buf __env);

  問:調用setjmp時傳遞__env的內容,還是傳遞指針?

  【5 頭文件】

  問:為什么標準頭文件都有類似以下的結構?

  #ifndef __INCvxWorksh

  #define __INCvxWorksh

  #ifdef __cplusplus

  extern “C” {

  #endif

  /*…*/

  #ifdef __cplusplus

  }

  #endif

  #endif /* __INCvxWorksh */

  【6 static關鍵字】

  請說出static關鍵字的3種用處:

  (1)用于全局變量;

  (2)用于局部變量;

  (3)用于函數。

  /* file.c */

  static int a;

  int b;

  static int fn()

  {

  static int x;

  int y;

  }

  【7 const關鍵字】

  7.1 const關鍵字的意義是什么?

  7.2 解釋以下的變量定義:

  const int a1;

  int const a2;

  const int *a3;

  int * const a4;

  int const * const a5;

  【8 volatile關鍵字】

  8.1 volatile意義?例如

  volatile int *p;

  8.2 volatile能和const一起使用嗎?例如

  volatile const int *p;

  【9 sizeof()】

  有以下定義:

  char *pmsg = “A”;

  char msg[] = “A”;

  char ch = ‘A’;

  問:

  sizeof(pmsg) = ?

  sizeof(msg) = ?

  sizeof(“A”) = ?

  sizeof(ch) = ?

  sizeof(‘A’) = ? (在C++中等于多少?)

  void f(char param[100])

  {

  // sizeof(param) = ?

  }

  【10 字符串】

  有以下代碼

  char *pmsg = “hello, world!”;

  strcpy(pmsg, “hi, there.”);

  試評論該代碼。

  【11 混合運算】

  有以下代碼:

  void foo()

  {

  unsigned int a = 6;

  int b = -20;

  (a+b > 6) ? puts(“> 6″) : puts(” < = 6″);

  }

  請問調用foo()的輸出?

  【12 內存訪問】

  有以下代碼:

  void fn()

  {

  int a[100];

  int *p;

  p = (int *)((unsigned int)a + 1);

  printf(“p=0x%x\n”, *p);

  }

  試評論以上代碼。

  【13 C庫函數】

  請說明以下函數的意義:

  void perror(const char *__s);

  fdprintf(int, const char *, …);

  isspace(), isxdigit(), strerr(), sprintf()

【c語言常見筆試題總結】相關文章:

C/C++程序員必備資料 常見筆面試題深入解析12-12

華為C語言筆試題12-12

華為筆試題(C語言)12-10

基礎C++/C語言筆試題分享11-21

yahoo在線筆試題(c語言)12-12

C語言筆試試題及答案07-31

c語言筆試題目及答案08-17

2015C語言筆試題及答案08-08

計算機C語言試題及答案02-25

2017年c語言面試筆試題11-22

亚洲制服丝袜二区欧美精品,亚洲精品无码视频乱码,日韩av无码一区二区,国产人妖视频一区二区
亚洲欧美步兵在线观看 | 中文日韩欧免费精品视频 | 欧美亚洲另类小说图片视频 | 亚洲日韩一区二区三区高清 | 天天噜天天视频在线高清 | 亚洲午夜福利网在线网站 |