当前位置:文档之家› C语言基础试题

C语言基础试题


1 void move(ulong *array,ulong n,ulong m)
2{
3 ulong *p;
4 ulong array_end;
5 ASERT(array);
6 ASERT(n>m);
7 for(p=array+n;p>array;p--)
8{
9
*p=*(p-1);
10 }
11 *array=ayyay_end;
12. 单选择 Char *pszResource[]={“soft disk”,”hard disk”,”Cray”,”on-line routhines”,”mouse”,”keyboard”,”power cables”}; pszResource[2]指向的是() A ”hard disk”存储的起始地址 B “Cray”存储的起始地址 C “soft disk”中字符 o 的起始地址 D “soft disk”中字符 f 起始地址
}
26. struct tagABC { char cB; char sC; char cD;
char 1A; }*pAbc;
pAbc=0x100000;


(ULONG)pAbc+0x100=0x
*)pAbc+0x100=0x ;
pAbc+0x100=0x ;(ULONG*)pAbc+0x100=0x
19. Enum ENUM_A { X1; Y1;
Z1=5; A1; B1; }; Enum ENUM_A enumA=Y1; Enum ENUM_A enumB=B1; 请问 enumA= ;enumB= ;
20. #define PCHAR char * PCHAR pch1,pch2;
Sizeof(pch1)= ; Sizeof(pch2)= ;
24.请问:ulsize 等于多少?() char c[]={‘c’,’h’,’i’,’n’,’a’}; ulSize=strlen(c); A.5 B.6 C..不确定
25.改错题 下列程序目的是要实现逆序打印,请指出其错误。 main() { char *src=”hello,world” char *dest=NULL; int len=strlen(str); dest=(char *)malloc(len); char *d=dest; char *s=sre[len]; while(len--!=0) { d++=s--; } printf(“%s”,dest); return 0;
C 语言基础试题
1. 指出其中的错误:
1 void Getresult(unsigned int uiM,unsigned int uiN)
2{
3 unsigned short usIndex;
4
5 If(0==uiN)
6{
7
return;
8}
9 for(usIndex=uiN;uiIndex<=uiM;usIndex=usIndex+uiN)
,sizeof(stMax)=
,sizeof(pstMax)=
28.编程题(用 C 语言作答) 现在要对一无序数组 array[]进行折半查找,请写出算法 int BinSearch(int
array[],int iValue,int iCount),array 代表被查数组,iCount 代表数组元素总数,iValue 代表被查元素值,前提假设是 array 中的值都是唯一不重复的,要求:如果在数 组中找到此元素则返回 1,没有找到则返回-1
C. data[4]+8; D. data+2*4+4;
10. UCHAR *pszTest=\\\0; UCHAR acutest[]=\\\0;
请问 sizeof(pszTest)= , sizeof(*pszTest)= , sizeof(aucTest);
11. char str[]=”ABCDE”; char *p=str; 请计算 size(str)= ,sizeof(p)= .
10 {
11
printf(“%u”,usIndex);
12 }
13 return;
14 }
2. 指出其中的错误:
1 int a[10];
2 int main()
3{
4 int *p;
5 int i;
6 p=a;
7 for(i=0;i<=10;i++)
8
{
9
scanf(“%d”,p++);
10 }
11 printf(“\n”);
5. 下面递归函数将调整 n 个整数的数据 Array,使其前面各顺序向后移 m 个位
置(n>m),最后 m 个数变成最前面的 m 个数。例如,1,2,3,4,5,6,7,8 顺序移动
3 个位置变成(6,7,8,1,2,3,4,5)请指出其实现的 3 个错误。假设不考虑堆栈的溢
出问题,也不考虑递归引起的效率问题。
21.挑单错 将数组的内容反序拷贝到一块内存中,并返回该内存。 Char *inverse(char a[]) { int len; int i; char *p; if(NULL=a) { return NULL; } Len=sizeof(a); p=(char *)malloc(len); if(NULL==p) { reutnr NULL; } for(i=0;i<len;i++); { p[i]=a[len-i-1]; } return p; }
A.15 B.14 C.13 D.12
23.设有如下定义:() int arr[]={6,7,8,9,10}; int *ptr; 则下列程序段的输出结果为() ptr=arr; *(ptr+2)+=2; printf(“%d,%d\n”,*ptr,*(ptr+2)); A.8,10 B.6,8 C.7,9 D.6,10
; ;(char
27. UCHAR *puCharArray[10][10];
typedef union unRec {
ULONG ulIndex; USHORT usLevel[6]; UCHAR ucPos; }REC_S; REC_S stMax,*pstMax; 四字节对齐方式时:sizeof(pucCharArray)= Sizeof(*pstMax)= .
嵌入式开发——C 语言面试题
1. 用预处理指令#define 声明一个常数,用以表示一年中有多少秒(忽略闰年问 题)
8. 程序的输出为: 1 void test() 2{ 3 signed char ch; 4 int sum; 5 ch=127; 6 sum=200; 7 ch++; 8 sum+=ch; 9 printf(“%d”,sum); 10 }
9. 对于一个数组 int data[5][4],data[4][2]的地址可以表示为() A. dat+4*4+2; B. data[4]+2;
14. UCHAR *pzTest=”hello”; UCHAR *pChar=NULL; Sizeof(*pzTest) ,sizeof(pChar) .
15. 单选 Struct tagStudent {
unsigned long num; unsigned long age; };
void fun() {
输出结果是() A.2 B.4 C.8 D16
16.[单选]设有以下定义: int a[4][3]={{1,2,3},{4,5,6},{7,8,9},{10,11,12}}; int (*prt)[3]=a,*p=a[0]; 则下列能够正确表示数组元素 a[1][2]的表达式是() A.*(ptr[1]+2*4) B.*(p+1*3+2) C.*(*(a+1*3*4)+2*4)
drawing
13. 有如下的 HASH 函数 1 Unsigned char hash(unsigned char *mac) 2{ 3 unsigned char uctmp; 4 uctmp=*mac+*(mac+1)+*(mac+2) 5 return(uctemp); 6}
已知
unsigned char cMAC[6]={0xa4,0xb5,0xc6,0xd7,0xe8,0xf9}; unsigned char *p1; unsigned char *p2; p1=cMAC; p2=p1+1; hash(p1)和 hash(p2)的值分别是(用 16 进制表示) 和 .
17. UCHAR *ppszTest[3]={“hello”,”okay”,”goodbye”}; UCHAR **ppChar=ppszTest; Sizeof(*ppszTest)= sizeof(*ppChar)=
18. char *pcColor=”world cup”; Char acColor[]=”world cup”; strlen(pcColor)= ; strlen(acColor)= ; sizeof(pcColor)= ; sizeof(acColor)= ;
12 m--;
13 if(m>0)
14 {
15 move(array,n,m);
16 }
17 return;
18 }
6. 指出下面这段代码中的错误:
1 unsigned long FUNC_B(unsigned long ulCount)
2{
3 unsigned long ulSum=0;
相关主题