你的那个C语言问题,我想回答,但提交不了,提示没有权限。。。
//Code::Blocks13.12#include<stdio.h>intmain(){chara[6]="12346";char*ptr=a;//a是一个指向字符数...
//Code::Blocks 13.12
#include<stdio.h>
int main()
{
char a[6]="12346";
char* ptr = a;//a是一个指向字符数组首地址指针常量,不能直接对a的值进行更改!
printf("All elements in the character array: ");
while(*ptr != '\0')
{
printf("%c ", *ptr);
ptr += 1;
}
ptr--;
printf("\nThe last element in the character array: %c\n", *ptr);
return 0;
}
输出结果:
All elements in the character array: 1 2 3 4 6
The last element in the character array: 6
Process returned 0 (0x0) execution time : 0.042 s
Press any key to continue. 展开
#include<stdio.h>
int main()
{
char a[6]="12346";
char* ptr = a;//a是一个指向字符数组首地址指针常量,不能直接对a的值进行更改!
printf("All elements in the character array: ");
while(*ptr != '\0')
{
printf("%c ", *ptr);
ptr += 1;
}
ptr--;
printf("\nThe last element in the character array: %c\n", *ptr);
return 0;
}
输出结果:
All elements in the character array: 1 2 3 4 6
The last element in the character array: 6
Process returned 0 (0x0) execution time : 0.042 s
Press any key to continue. 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询