重庆某公司笔试题
2. int (p)[5]与int*p[5]有什么区别?
3. Main( )
{
Int a,b,c,d;
A = 6;
B=a++;
C=++a;
D=10*a++;
Printf(“b,c,d:%d,%d,%d”,b,c,d);
Return 0;
}
4. 有一个结构声明为struct data{};请写出使用typedef重定义一个指向struct data的类型
5. 设cpu为32位,有以下说明和定义:
#include <stdio.h>
int main(){
typedef union
{
long i;
int k[8];
char c;
}DATE;
struct data
{
int cat;
DATE cow;
double dog;
}too;
DATE max;
printf("%d",sizeof(struct data)+sizeof(max));
return 0;
}
6. 请找出下面代码中的所有错误,说明,一下代码是把一个字符串倒序,如“abcd”倒序后变为“dcba”
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char *src = "hello,world";
char *dest = NULL;
int len = strlen(src);
dest = (char*)malloc(len);
char* d = dest;
char* s = src[len];
while(len-- !=0)
d++ = s--;
printf("%s",dest);
return 0;
}
7. 编写strcmp函数,已知strcmp函数的原型是int strcmp(const char*str1, const char*str2),str1与str2为需要比较的2个字符串。
8. 下面三个变量有什么区别?
char const *p;
char * const p;
const char *p;
9. 写出floatx与“零值”进行比较的if语句,判断×是否等于零。
10. Static
11. Volatile
12. string.h
#面试##笔试#