一个比较白痴的C语言初学者求助!!!

来源:百度知道 编辑:UC知道 时间:2024/05/07 18:19:10
我想编写一个简单的电话本,这个是我写的程序,不过没法运行,请高帮忙给调试下,谢谢!!
#include<stdio.h>
main()
{
int scan(char a,char b);
static char list[10][10];/*定义电话本数组*/
int a;
char name;
int j=0;
printf("press 1 for save new name press 2 to scan old name");
scanf("%d",&a);
if(a==1)/*按1新编辑名片卡*/
{printf("please input the new name ");
for(j=0;j<10;j++)
scanf("%c",&list[0][j]);/*输入新的名字,并且输入到系统中*/
printf("please input the telephone number:");
for(j=0;j<10;j++)
scanf("%d",&list[1][j]);} /*输入电话号码*/

if(a==2)/*按2进行历史记录查询*/
{
printf("please input the name");
scanf("%s",&name);
for(j=0;j<10;j++);
if(scan(list[0][j],name))
{
printf("his phone number is %d",list[0][j]);}
}
}

int scan(char a,char b)
{int c;
c=(a==b);
return c;
}

直接编译,直接运行~逻辑搞对就没问题了
#include<stdio.h>
#include<string.h>
#define N 10
main()
{
char list_name[N][80];/*定义电话本数组*/
char list_phone[N][80];/*电话号码*/
char name[80];
int i,j;

/*输入*/
for(j=0;j<N;j++)
{
printf("please input the new name to input:\n");
scanf("%s",&list_name[j]);/*输入新的名字,并且输入到系统中*/
printf("please input the telephone number:\n");
scanf("%s",&list_phone[j]);
} /*输入电话号码*/

/*查询*/
printf("please input the name to search\n");
scanf("%s",&name);
for(i=0;i<N;i++)
{
if(strcmp(list_name[i],name)==0)
{
printf("his phone number is %s\n",list_phone[i]);
break;
}

}
getch();

}

唉,scanf("%d",&list[1][j]);} /*输入电话号码*/