帮忙看下这个程序为什么不能运行?
#include <stdio.h>#include <string.h>
#include <stdlib.h>
#include <time.h>
#define NUM 10 //最大容纳数据的消费者数量
typedef struct node_card
{
unsigned long m_Money;//办卡金额
unsigned long m_Counter;//消费次数
unsigned long m_FeeMonSum;//累计消费金额
struct tm *m_Time;//(有效值为年/月/日)
unsigned int m_ID; //卡号
char *m_Name; //持卡人名称
char *m_Ph;//联系电话
short m_Discount; //折扣
}Card;
Card customers[NUM];
unsigned int Counter; //计数器
void get_customer_msg(void);
void auto_deal(unsigned int coun);
void print_customers_msg(void);
int wmain(void)
{
get_customer_msg();
print_customers_msg();
return 0;
}
/*
*录取客户信息
*/
void get_customer_msg(void)
{
unsigned int sum;
printf("输入持卡人数: "); scanf("%u", &sum);
while (0 != sum--)
{
printf("输入持卡人姓名: ");
customers[Counter].m_Name = (char*) malloc (20*sizeof(char));
scanf("%s", customers[Counter].m_Name);
printf("输入持卡人联系电话: ");
customers[Counter].m_Ph = (char*) malloc (20*sizeof(char));
scanf("%s", customers[Counter].m_Ph);
printf("输入办卡金额: ");
scanf("%u", &customers[Counter].m_Money);
auto_deal(Counter);
customers[Counter].m_ID = Counter+1;
++Counter;
}
}
void auto_deal(unsigned int coun)
{
time_t t;
if (customers[coun].m_Money >= 10000)
{
customers[coun].m_Discount = 5;
}
else if (customers[coun].m_Money >= 5000)
{
customers[coun].m_Discount = 6;
}
else if (customers[coun].m_Money >= 2000)
{
customers[coun].m_Discount = 8;
}
else if (customers[coun].m_Money >= 1000)
{
customers[coun].m_Discount = 9;
}
else
{
customers[coun].m_Discount = 10;
}
customers[coun].m_Counter = 0;
customers[coun].m_FeeMonSum = 0;
customers[coun].m_Time = (struct tm*) malloc (sizeof(struct tm));
t = time(NULL);
customers[coun].m_Time = localtime(&t);
}
/*
*打印客户的全部信息
*/
void print_customers_msg(void)
{
unsigned int index = 0;
while (Counter != index)
{
printf("卡号: %d\n", customers[index].m_ID);
printf("持卡人: %s\n", customers[index].m_Name);
printf("电话: %s\n", customers[index].m_Ph);
printf("注册日期: %d %d %d\n", customers[index].m_Time->tm_year+1900,
customers[index].m_Time->tm_mon, customers[index].m_Time->tm_mday);
printf("办卡金额: %u\n", customers[index].m_Money);
printf("累计消费: %u\n", customers[index].m_FeeMonSum);
printf("消费次数: %u\n", customers[index].m_Counter);
printf("消费折扣: %u\n", customers[index].m_Discount);
++index;
}
}