一个初级C语言问题(使用指针的问题)请看一下

来源:百度知道 编辑:UC知道 时间:2024/05/10 13:49:53
#include"stdio.h"
#include"conio.h"
void main()
{
int j,k=1,m,a[12],*P=a;
printf("the first %x\n",P);
m=&a[0];
printf("the first %x",m);
/*getch(); */
/*printf("the one ~!");*/
for(j=0;j<12;j++)
{
scanf("%d",a[j]);
}
/*printf("the second %f",P);*/
for(j=0;j<12;j++)
{
/*printf("the two ~!");*/
printf("\n*p=%8d\t",*P++);
/*printf("the 3 %f",P);*/
/*if(k%4==0)*/
printf("-> ");
k++;
P--;
printf("*** %x ***",P);
P++;

}
/*printf("the threee~!");*/
/*for(j=0;j<12;j++)
printf("%2d",a[j]);*/
getch();

}
为什么会输出的是乱码啊????
不是

你这里有点问题,我给你改了,并且VC6.0调试了,显示无误了。看看是不是符合你的要求。 

#include"stdio.h" 

#include"conio.h" 

void main() 

int j,k=1,m,a[12],*P=a; 

printf("the first %x\n",P); 

m=(int)&a[0]; /*这里有点小问题,m为整型,最好强制转换成整型,不然VC6下调试有错*/ 

printf("the first %x",m); 

/*getch(); */ 

/*printf("the one ~!");*/ 

for(j=0;j<12;j++) 

scanf("%d",&a[j]); /*你的源程序这里有问题,赋值得用&,我给你改了,没问题了*/ 

/*printf("the second %f",P);*/ 

for(j=0;j<12;j++) 

/*printf("the two ~!");*/ 

printf("\n*p=%8d\t",*P++); 

/*printf("the 3 %f",P);*/ 

/*if(k%4==0)*/ 

printf("-> ");