2013-11-24 74 views
-2

我正在爲我的C類入門的項目工作,並遇到了一個障礙...我要拋出測試階段,所以請忽略所有的打印語句。試圖初始化它時未定義的參考

這裏是代碼塊告訴我:

ERROR: undefined reference to `BUYTICKET'| 

任何方式,我有麻煩時,我嘗試初始化函數。 (或稱之爲兩者之一。)

這裏是我的代碼:(的部分內容已被省略做窺探同學的可能性

#include <stdio.h> 
#include <stdlib.h> 


int BUYTICKET (float price_of_ticket,float price_presold, int amt_of_tickets_sold); 
// include functions here. you will need around 10 
int main() 
{ 
    int i,j; 

    //opens file 
    FILE * ifp; 
    ifp = fopen("input.txt", "r"); 
    //created variables for line one of text document 
    float price_pretickets,price_tickets; 
    int amt_presold; 

    //scan in first line. 
    fscanf(ifp, "%f", &price_pretickets); 
    fscanf(ifp, "%f", &price_tickets); 
    fscanf(ifp, "%d", &amt_presold); 
    printf("%f %f %d\n", price_pretickets,price_tickets, amt_presold); 
    //Scaning in the second line of code 

    int num_of_events; 
    fscanf(ifp, "%d", &num_of_events); 
    printf("\n%d\n", num_of_events); 
    int c =0; 
    char command[16]; 
    while (c<num_of_events) 
    { 
     c++; 

     fscanf(ifp, "%s", command); 
     printf("%s", command); 

     int amt_of_tickets_sold; 
     if (strcmp(command, "BUY") == 0) 
     { 
      fscanf(ifp, "%s", command); 
      printf(" %s ", command); 
      if (strcmp(command, "TICKET")== 0) 
      { 

      BUYTICKET(price_tickets, price_pretickets,amt_presold); //ERROR!! 
      fscanf(ifp, "%s", command); 
      printf("\n %s\n", command); 

      //function 


      } 

      else if (strcmp(command, "RAFFLE") == 0){ 
       fscanf(ifp, "%s", command); 
       printf("\n%s\n", command); 
      } 
      else if (strcmp(command, "DRINK")==0) 
       ;//function for buy raffle 
     } 
     else if (strcmp(command, "BIDTERM")==0) 
      ;//function for BIDTERM 
     else if (strcmp(command, "CLOSEAUCTION")==0) 
      ;//function for CLOSEAUCTION 
     else if (strcmp(command, "AWARD")==0) 
      fscanf(ifp, "%c", &command); 
     if (strcmp(command, "RAFFLE")==0) 
     { 
     }//function for raffle 
     else if (strcmp(command, "AUCTION")==0) 
      ;//function for AUCTION 
     else if (strcmp(command, "PERSON")==0) 
      ;//function for AWARD PERSON 

     else if (strcmp(command, "TOTAL")==0){ 
      fscanf(ifp,"%s", command); 
     printf(" %s ", command); 
     } 

    } 

    //go ahead and determine the actions the text documents wants you to take using if statements. 
    // use strcmp to compare between buy tcikets buy drink ect. 
    // 




int BUYTICKET(float price_of_ticket,float price_presold, int amt_of_tickets_sold) 
{ 

printf("%f %f %d", price_of_ticket,price_presold, amt_of_tickets_sold); 

} 


    return 0; 


} 

thak你們的俯瞰我的問題

回答

2

您限定主函數內BUYTICKET功能。外面定義它。

不能大體限定其他功能內部的功能。

+0

只是想出了哈哈謝謝! – user3026473

0

函數定義不能存在於其他函數的定義中。你在主內定義BUYTICKET這是非法的。