项目九测试
1.变量的指针,其含义是指该变量的( )。
A:一个标志
B:名
C:值
D:地址

答案:D
2.已有定义 int k=2;int
*ptr1,*ptr2;且 ptr1 和 ptr2 均已指向变量k,下面不能正确执行的赋值语句( )。
A:ptr2=k
B:k=*ptr1+*ptr2
C:ptr1=ptr2
D:. k=*ptr1*(*ptr2)
3.若有语句: int *p,a=4; 和 p=&a ;下面均代表地址的一组选项是( )。
A:&a,&*p,p
B:*&p,*p,&a
C:&*a,&a,*p
D:a,p,*&a
4.下面判断正确的是( )。
A:char *a=
” china等”价;于 char *a; *a=
” china ” ;
B:char c[4]=
” abc ” ,d[4]=
等价abc于 ”;char c[4]=d[4]=” abc ” ;
C:char str[10]={
“ china等价”于}; char str[10]; str[ ]={
“ china
” ;}
D:char *s=
” china等”价于; char *s; s=
” china ” ;
5.设有程序段 :char s[ ]=” china ” ; char *p则;下p=s面叙;述正确的是( )。
A:*p 与 s[0] 相等
B:数组 s 中的内容和指针变量p 中的内容相等
C:s 和 p 完全相同
D:s 数组长度和p 所指向的字符串长度相等
6.以下与库函数strcpy(char *p1,char *p2) 功能不相等的程序段是( ).
A:strcpy1(char *p1,char *p2)
{ while ((*p1++=*p2++)!=) ; } ’
B:strcpy4(char *p1,char *p2)
{ while (*p2) *p1++=*p2++ ; }
C:strcpy2(char *p1,char *p2)
{ while ((*p1=*p2)!=) { p1++;’ p2++ } }
D:strcpy3(char *p1,char *p2)
{ while (*p1++=*p2++) ; }
7.给出以下定义,
const char* p1 = “hello”;
char* const p2 = “world”;
下列哪些操作是合法的( )
A:p2++;
B:p1[2] = ‘w’;
C:p1++;
D:p2[2] = ‘l’;
8.下列函数定义中,有语法错误的是( )
A:int *fun(int *x,int y)
{return x+=y;}
B:void fun(int x,int *y)
{*x = *y;}
C:void fun(int *x,int y)
{*x += y;}
D:void fun(int x,int *y)
{x* = *y;}
9.

程序 #include <stdio.h> main() { int a,b,c=246; a=c/100%9; b=(-1)&&(-1); printf("%d,%d\n",a,b); } 输出结果是( )。


A:2,1 B:3,2 C:2,-1
D:4,3 10.若有说明: int *p1, *p2,m=5,n;以下均是正确赋值语句的选项是( )。
A:p1=&m; p2=p1 ;
B:p1=&m; *p1=*p2 ;
C:p1=&m; p2=&p1 ;
D:p1=&m; p2=&n; *p1=*p2 ;

温馨提示支付 ¥3.00 元后可查看付费内容,请先翻页预览!
点赞(172) dxwkbang
返回
顶部