c语言 (高手请进)

[复制链接]
查看11 | 回复3 | 2008-12-25 11:08:07 | 显示全部楼层 |阅读模式
头文件和函数声明已略~
int judgecustomer(char *lastname1, char *firstname1, long code1, struct customer customer[60])
{
int j, r, q, w=0, x=0;
char *s1, *s2, *s3, *s4;
for(j=0; j<60; j++)
{
*s1=*customer[j].lastname;
*s2=*lastname1;

*s3=*customer[j].firstname;
*s4=*firstname1;
r=strcmp(s1,s2);
q=strcmp(s3,s4);
if(r==0 && q==0)
{
puts("The name you enter is correct.");
w++;
}
if(code1 == customer[j].code)
{
puts("The code you enter is correct.");
x++;
}
if(w==1 && x==1)
{

puts("Identified successfully");

return 40;
}

else

return 30;

}
}
这个子函数用来判断用户输入的lastname 和 firstname 以及 code 是否正确。编译器不报错,但运行时会出错。
请高手看看代码有何错误。
谢谢~

回复

使用道具 举报

千问 | 2008-12-25 11:08:07 | 显示全部楼层
nt judgecustomer(char *lastname1, char *firstname1, long code1, struct customer customer[60]){int j, r, q, w=0, x=0;char *s1, *s2, *s3, *s4;for(j=0; j<60; j++){s1=customer[j].lastname;//*s1=*customer[j].lastname指针赋值,不需要*了吧s2=lastname1;
//同上s3=customer[j].firstname; //同上s4=firstname1;
/...
回复

使用道具 举报

千问 | 2008-12-25 11:08:07 | 显示全部楼层
应该是指针有问题 要赋初值或者把指针改成字符数组用strcpy赋值就好了...
回复

使用道具 举报

千问 | 2008-12-25 11:08:07 | 显示全部楼层
去掉for循环里的 *...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行