下载此文档

嵌入式面试问题及解答(英文)word版.doc


文档分类:IT计算机 | 页数:约16页 举报非法文档有奖
1/16
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/16 下载此文档
文档列表 文档介绍
Basic c question.
1.
Question:
where in memory the variables are stored?
Local variables, global variables, static.
Answer
Local variables sit in Stack.
Global and static goto Data segment.
Dynamic memory comes from Heap.
2.
Question
can you explian the meaning for the follwoing program
char *c1, *c2, *c3, *c4, *c5 ;
char analysis[8] = {'a', 'n', 'a', 'l', 'y', 's', 'i' ,'s'};
int main()
{
c5 = c4 = analysis;
++c4;
c3 = &analysis[6];
c2 = c5 + 2 ;
c1 = &analysis[7] - 3 ;
printf ("%c\t%c\t%c\t%c\t%c", *c1,*c2,*c3,*c4,*c5);
return 0;
}
Answer
c1, c2, c3, c4 and c5 are pointers (which can hold addresses).
analysis is an array variable which is holding the string "analysis".
>c5 = c4 = analysis;
The starting address of the array is given to c5 and c4. Hence they point to first character 'a' in the array.
>++c4;
c4 is incremented by 1. Hence points to 'n' in the array.
>c3 = &analysis[6];
c3 is given the address of 7th character (count from 0) of the array. Hence c3 points to character 'i'.
>c2 = c5 + 2 ;
c5 points to first character. plus 2 means, c2 points to 3rd character 'a' (second 'a' in the string).
>c1 = &analysis[7] - 3 ;
c1 points to 3rd character from the end (not counting the last character).
c1 holds the address. *c1 means the data strored at c1. Since c1 points to 3rd character from the end (that is 5th character - count starts from 0), *c holds character 'y'.
Hence *c1 will print 'y' on the screen.
Similarly for other pointer variables *c2, *c3, *c4 and *c5
3.
Question:
a=5 b=10 c=7
(a>c)?a:((b>c)?b:c)
Answer: 10
4
Question : How do you declare an array of N pointers to functions returning
pointers to functions returning pointers to characters?
A. char *(*(*a[N])())();
B. Build the declaration up incrementally, using typedefs:
C. Use the cdecl program, which turns English into C and vice
versa:
D. All of the above.


Answer : D
5
Ques

嵌入式面试问题及解答(英文)word版 来自淘豆网www.taodocs.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数16
  • 收藏数0 收藏
  • 顶次数0
  • 上传人精品小课件
  • 文件大小57 KB
  • 时间2021-05-03