文件名称:富士通笔试题与解答 经典
文件大小:40KB
文件格式:DOC
更新时间:2013-01-08 15:18:46
14. 写出判断ABCD四个表达式是否正确, 若正确, 写出经过表达式中a的值
经典实用: 1. 某32位系统下, C++程序,请计算sizeof 的值 #include #include void Foo ( char str[100] ) { printf("sizeof(str)=%d \n", sizeof(str) ); } main() { char str[] = "www.ibegroup.com"; char *p1 = str ; int n = 10; void *p2 = malloc( 100 ); printf("sizeof(str)=%d \n", sizeof(str) ); printf("sizeof(p1)=%d \n", sizeof(p1) ); printf("sizeof(n)=%d \n", sizeof(n) ); printf("sizeof(p2)=%d \n", sizeof(p2) ); Foo(str); } 答:(1)17 (2)4 (3) 4 (4)4 (5)4 2. 回答下面的问题 (1) 头文件中的 ifndef/define/endif干什么用? 预处理 答:防止头文件被重复引用 (2) #include 和 #include "filename.h" 有什么区别? 答: 对于#include ,编译器从标准库路径开始搜索filename.h 对于#include "filename.h" ,编译器从用户的工作路径开始搜索filename.h (3) 在C++ 程序中调用被 C 编译器编译后的函数,为什么要加 extern “C”声明? 答:函数和变量被C++编译后在符号库中的名字与C语言的不同,被extern "C"修饰的变量和函数是按照C语言方式编译和连接的。由于编译后的名字不同,C++程序不能直接调用C 函数。C++提供了一个C 连接交换指定符号extern“C”来解决这个问题。