好的,所以我一直在研究我的大腦對抗人行道,試圖弄清究竟哪個參數名被省略。這是我從構建消息中得到的唯一的錯誤,警告或提示。「錯誤:省略參數名稱」並將輸入文件作爲參數傳入
行
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參數在那裏。使用專有名稱和一切。我的編譯器整天都很時髦,這只是一個副作用嗎?
另外,出於某種原因,我無法在函數中傳遞「ifp」作爲參數,所以我可以從所述函數中的輸入文件中讀取數據。我一直在努力讓這個工作,但我沒有做的是工作。
您的意思是'無效readTickets(結構tickets_s訂票,INT earlyTix,INT doorTix)'? – AlexD 2014-09-26 20:35:55
??這個世界上的事情如何導致一切都起作用? – Darksider13 2014-09-26 20:38:32
'struct tickets_s'是參數類型,參數本身缺失。也許你的意思是'struct tickets_s tickets'。我用CAPS來強調。但即使你使用'TICKETS',它也可以工作,因爲你擁有全局變量'tickets'。 – AlexD 2014-09-26 20:41:29