概述
1. 程序运行结果: ________5,4_____________________
2. 程序运行结果: _________10,2____________________
3. 程序运行结果: ___________4,5__________________
4. 程序运行结果: ________4,2_____________________
5. 程序运行结果: _________bcd____________________
6. 程序运行结果: ___________a0babc__________________
char str1[10] = “a0b”; strcat(str1,”abc”); printf(“%sn”,str1);//字符串连接
8. char* p1 = “abcd”; char p2[] = “abcd”; *p1 = ‘b’; *p2 = ‘c’; 哪个语句不对,为什么?
*p1='b' 这个语句不对 因为p1指向字符串常量区 值不能更改
9. 程序运行结果: ______10,20_______________________
Void Func(int a, int b)
{
int temp;
temp = a;
a = b;
b = temp;
}
int main()
{
int a = 10; b = 20;
Func(a,b);
printf(“%d %dn”,a,b);
10. 程序运行结果: __________100___________________
void Func(int** p)
{
*p = malloc(4);
**p = 100;
}
int main()
{
int *p = malloc(4);
*p = 10;
Func(&p);
printf(“%dn”,*p);
}
11. 程序运行结果: ___________4__________________
Void Func(int arr[10]);
{
printf(“%dn”,sizeof(arr));
}
Int main()
{
int arr[10] = {1,2,3,4,5,6,7,8,9,10};
Func(arr);
}
12. 程序输出结果:______3,__5,____5______________
int get(int val)
{
static int s1,s2=3;
if(val >0)
{
s2 = val;
}
return s1+s2;
}
printf(“%d”,get(0));
printf(“%d”,get(5));
printf(“%d”,get(0));
13. 程序输出结果:________5,5,5__________________
int Func(char* str)
{
Printf(“%dn”,strlen(str));
Return strlen(str);
}
Int main()
{
Char* str = “abcde”;
Func(str);
Printf(“%dn”,Func(str));
}
14. Int a = 10; int b = 11; int const* p1 = &a; int * const p2 = &b;
p1 = &b; p2 = &a; 哪个语句不对? _________p2=&a p2的值不能改 const修饰的是p2____________
*p1 = 100; *p2 = 100; 哪个语句不对? _______*p1=100 *p1的指不能改 const修饰的是*p1_______________
15. 程序输出结果:______1____________________
Void Func(int** p)
{
int* a = (char*)malloc(4);
*a = 1;
*p = a;
}
Int main()
{
int a = 10;
int* p = &a;
Func(&p);
Printf(“%dn”,*p);
}
最后
以上就是烂漫心锁为你收集整理的字符串习题的全部内容,希望文章能够帮你解决字符串习题所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复