两个程序都是发生编译执行后应用错误,请高手指教!x
1:#include<stdio.h>
#include<string.h>
int main(void)
{
int k,i,j;
char *p[]={"china","American","","Italy","Australia"},*t;
for(i=0;i<4;i++)
for(j=0;j<4;j++)
if(strcmp(p[j],p[j+1])>0)
{ t=p[j];p[j]=p[j+1];p[j+1]=t;}
for(k=0;k<4;k++)
printf("%-12s\n",p[k]);
return 0;
}
2:
#include<stdio.h>
int main()
{
struct key
{
unsigned int i;
int j;
char m;
};
struct key hat,*p;
p->i=2;
p->j=3;
p->m='k';
printf("%d\n%d\n%c",p->i,p->j,p->m);
return 0;
}
//以上程序编译通过没错误,但执行的时候出现“内存错误”