|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
求救:这个程序执行提示内存不可读:请帮忙看下,谢谢!
#include<stdio.h>
void main()
{
struct friends_list{
char name[20];
int age;
int telephone[20];
char address[20];
}friends[5],temp;
int i,j;
printf("Please input your friends' information:\n");
for(i=0;i<5;i++)
{
printf("please input his/her name:\n");
scanf("%s",&friends[i].name);
printf("please input his/her birthday:\n");
scanf("%d",&friends[i].age);
printf("please input his/her telephone no.:\n");
scanf("%d",&friends[i].telephone);
printf("please input his/her address:\n");
scanf("%s",&friends[i].address);
}
for(i=0;i<5;i++)
{
for(j=i;j<5;j++)
{
if(friends[i].age<friends[j].age)
{
temp=friends[j];
friends[j]=friends[i];
friends[i]=temp;
}
}
}
printf("Below is the list which was sorted and you want!\n");
for(i=0;i<5;i++)
printf("s% d% %d %s\n",friends[i].name,friends[i].age,friends[i].telephone,friends[i].address);
} |
|