标题:帮忙看下这个程序为什么不能运行?
只看楼主
ahtar
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2011-5-14
结帖率:100%
已结贴  问题点数:10 回复次数:5 
帮忙看下这个程序为什么不能运行?
#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;
    }
}
搜索更多相关主题的帖子: 联系电话 计数器 消费者 
2011-05-16 00:10
hjywyj
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:3
帖 子:1114
专家分:2611
注 册:2010-4-14
得分:2 
int wmain(void)//是不是多了个m?
2011-05-16 06:14
lucky563591
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:4
帖 子:765
专家分:2103
注 册:2009-11-18
得分:2 
编译时不是有出错位置的?
2011-05-16 07:53
w123012306
Rank: 9Rank: 9Rank: 9
来 自:湖南
等 级:蜘蛛侠
威 望:4
帖 子:307
专家分:1180
注 册:2010-4-22
得分:2 
是main 不是wmain!

楼上,楼下的一定要幸福开心哦!
2011-05-16 08:24
laoyang103
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:内蒙古包头
等 级:贵宾
威 望:19
帖 子:3082
专家分:11056
注 册:2010-5-22
得分:2 
楼上错了 如果是VC++6.0 会有这样的宏定义

#define wmain main

                                         
===========深入<----------------->浅出============
2011-05-16 09:42
ahtar
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2011-5-14
得分:0 
都不是那些问题,我也找了半天没找出来
2011-05-16 16:28



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-340009-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.684658 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved