"错误:省略参数名称"并将输入文件作为参数传递

时间:2014-09-26 20:33:05

标签: c function struct parameters

好吧,所以我一直在绞尽脑汁,试图找出究竟是什么参数名称被忽略了。这是我唯一的错误,警告或说明我从构建消息中获取。

void readTickets(struct tickets_s, int earlyTix, int doorTix) {

作为

的一部分
#include <stdio.h>
#include <string.h>
#include <math.h>

//Establishing maximum size of array values
#define MAXSIZE 100
#define NUMDRINKS 10
#define MAXPRIZES 100
#define MAXGUESTS 1000
#define MAXRAFFLE 100000

//Establishing struct related to variables for tickets to the ball
struct tickets_s {
    double prePrice;
    double doorPrice;
    double guests[MAXGUESTS];
    int totalTix;
};

//Establishing struct for drink variables
struct drinks_s {
    int drinks[NUMDRINKS];
    double drinkPrices[NUMDRINKS];
};

//Establishing struct for variables related to the raffle
struct raffle_s {
    int raffleGuests[MAXRAFFLE];
    int prizeCount[MAXPRIZES];
    double itemValue[MAXPRIZES];
    double rafflePrice;
};

//Vars for amount of pre-sale tickets, door sale tickets and the totals for drinks, raffle and revenue
FILE* ifp;
int earlyTix, doorTix;
double totalDrinks;
double totalRaffle;
double totalRevenue;

//Renaming structs
struct tickets_s tickets;
struct drinks_s drinks;
struct raffle_s raffle;

void readTickets(struct tickets_s, int earlyTix, int doorTix);

int main() {

    char fileName[MAXSIZE];

    printf("Enter the name of the input file (including file extension)\n");
    scanf("%s", fileName);

    fopen(fileName, "r");
    readTickets(tickets,earlyTix,doorTix);

}

void readTickets(struct tickets_s, int earlyTix, int doorTix) {

    fscanf(ifp, "%d%d", &tickets.prePrice, &tickets.doorPrice);
}

我不知道这个参数名称的遗漏是什么。 struct参数就在那里。使用正确的名称和一切。我的编译器整天都很时髦,这只是一个副作用吗?

另外,出于某种原因,我无法通过&#34; ifp&#34;作为函数中的参数,所以我可以从所述函数中的输入文件中读取数据。我一直试图让它工作,但我所做的一切都在起作用。

1 个答案:

答案 0 :(得分:0)

评论员AlexD帮我解决了一个我忽略的愚蠢错误。谢谢Alex。

&#34;你的意思是无效readTickets(struct tickets_s TICKETS,int earlyTix,int doorTix)? - AlexD&#34;