第八章 善于使用指针:8.1 指针变量的定义和引用8.2 指针作为函数参数8.3 通过指针引用数组8.4 通过指针引用字符串8.1指针变量的定义和引用:指针变量的定义和引用[单选题]有以下程序
8.2指针作为函数参数:指针作为函数参数
8.3通过指针引用数组:通过指针引用数组
8.4通过指针引用字符串:通过指针引用字符串
8.5善于使用指针例题讲解(1):善于使用指针例题讲解(1)
8.6善于使用指针例题讲解(2):善于使用指针例题讲解(2)
8.7善于使用指针例题讲解(3):善于使用指针例题讲解(3)
void f( int y,int *x)
{y=y+*x; *x=*x+y;}
main( )
{ int x=2,y=4;
f(y,&x);
printf(“%d %d ”,x,y);
} 执行后输出的结果是选项:[4 2, 8 4, 2 4, 4 8]
[单选题]以下sstrcpy( )函数实现字符串复制,即将t所指字符串复制到s所指向内存空间中,形成一个新的字符串s。请填空。
void sstrcpy(char *s,char *t)
{ while(*s++=______);}
main( )
{ char str1[100],str2[]=”abcdefgh”;
sstrcpy(str1,str2);
printf(“%s ”,str1);
}
选项:[*t++, *t, *s, *s++]
[单选题]#include <stdio.h>
void f(int *p,int *q);
main()
{ int m=1,n=2,*r=&m;
f(r,&n); printf(“%d,%d”,m,n); }
void f(int *p,int *q)
{p=p+1;*q=*q+1;}
程序运行后输出的结果是选项:[1,2, 1,3 , 2,3, 1,4]
[单选题]以下程序的输出结果是__________
#include<stdio.h>
main()
{ int a[5]={2,4,6,8,10}, *p;
p=a; p++;
printf(“%d”,*p);
}选项:[2, 5, 6, 4]
[单选题]#include <stdio.h>main(){ char *a[ ]={"abcd","ef","gh","ijk"}; int i; for(i=0;i<4;i++) printf("%c",*a[i]); }
程序运行后输出的结果是
选项:[dfhk, abcd, abcdefghijk, aegi ]
[单选题]#include<stdio.h>
main(){char *s=“ABC”;
do
{printf(“%d”,*s%10);s++;} while(*s); }字母A的ASCII码值为65.程序的输出结果是选项:[656667, 567, ABC, 5670]
[单选题]以下程序的输出结果是________
#include<stdio.h>
void swap(int *a,int *b)
{ int *t;
{ t=a; a=b; b=t; } } main()
{ int i=3,j=5,*p=&i,*q=&j;
swap(p,q); printf(“%d %d ”,*p,*q);
}
选项:[5 3, 3 5 53, 3 5]
[单选题]#include<stdio.h>void fun(char *s){ while(*s) { if(*s%2==0) printf("%c",*s);s++; }}main(){ char a[]={"abcd"}; fun(a);printf("");}
字母a的ASCⅡ码值为97,程序的输出结果是
选项:[cd, abcd, bd, ab]
[单选题]下列函数的功能是
fun(char *a,char *b)
{ while((*b=*a)!=''){a++;b++;}}选项:[将a所指字符串和b所指字符串进行比较 , 将a所指字符串赋给b所指空间 , 使指针b指向a所指字符串, 检查a和b所指字符串中是否有'' ]
[单选题]#include <stdio.h>int b=2;int fun(int *k){ b=*k+b;return(b);}main(){ int a[10]={1,2,3,4,5,6,7,8},i; for(i=2;i<4;i++) {b=fun(a)+b;printf("%3d",b);} }程序运行后输出的结果是
选项:[10 16, 6 14, 10 12, 8 10]
[单选题]#include <stdio.h>
main()
{ int m=1,n=2,*p=&m,*q=&n,*r;
r=p;p=q;q=r;
printf("%d,%d,%d,%d",m,n,*p,*q);
}
程序运行后的输出结果是选项:[1,2,2,1, 1,2,1,2, 2,1,2,1, 2,1,1,2]
[单选题]#include<stdio.h> #define N 8 void fun(int *x,int i) { *x=*x+i;} main() {int a[N]={1,2,3,4,5,6,7,8},i; fun(a,2); for(i=0;i<N/2;i++) { printf(“%d”,a[i]);} printf(“”);} 程序运行后的输山结果是
选项:[3234, 1234, 1313, 2234]
[单选题]#include <stdio.h>
#include <string.h>
main()
{char str[][20]={"One*World","One*Dream!"}; char *p=str[1];
printf(“%d,”,strlen(p));
printf("%s",p); }
程序运行后的输出结果是
选项:[10,One*Wor , 10,One*Dream! , 9,One*Dream!, 9,One*World ]
[单选题]下列语句组中,正确的是选项:[char *s;s={"Olympic"};, char s[7]; s="Olympic";, char s[7];s={"Olympic"};, char *s;s= " Olympic ";]
[单选题] void fun(char *c,int d) { *c=*c+1; d=d+1; printf(“%c,%c,”,*c,d); }
main() { char b=‘a’,a=‘A’; fun(&b,a); printf(“%c,%c”,b,a); }程序运行后的输出结果是
选项:[b,B,B,A, b,B,b,A, a,B,a,B, a,B,B,a ]
[单选题]设有定义double a[10],*s=a;以下能够代表数组元索a[3]的是选项:[*(s+3) , (*s)[3] , *s+3, *s[3] ]
温馨提示支付 ¥1.00 元后可查看付费内容,请先翻页预览!