2014-12-06 60 views
-1

每次嘗試編譯時都會收到錯誤。這可能是愚蠢的,但我無法弄清楚。這是錯誤: aldrbw01 @材:〜/ project5 $使文件之間的結構

gcc的-g -c crawler.c -o crawler.o

crawler.c:在函數 '履帶':

crawler.c:12:錯誤:預期 '{' 前 '*' 標記

化妝:*** [crawler.o]錯誤1

#include "crawler.h" 
#include "indexPage.h" 
//My Carwler 

int checkIndex(char* url, char** urlArray, const int MAX_N); 
int getLink(const char* srcAddr, char* link, const int maxLinkLength); 
char** missionControl(const char* FILE_NAME, const int Max_N); 


char** crawler(const char* FILE_NAME, const int Max_N){ 
char** URLs; 
queryHelper **structArray = malloc(sizeof(struct *wordControl)*50); 
URLs= missionControl(FILE_NAME, Max_N); 
return URLs; 
} 


char** missionControl(const char* FILE_NAME, const int Max_N){ 

const int MAX_BUFFER = 1000; 
    int cursor = 0; 
    int x; 
    char** urlArray = malloc(sizeof(char*)*Max_N); 

    for(x=0; x<Max_N; x++) { 
     urlArray[x] = NULL; 
    } 
    FILE *file = fopen(FILE_NAME, "r"); 
    char* url; 
    url = malloc(sizeof(char)*1000); 
    int* hoplimit; 
    hoplimit = malloc(sizeof(int)); 
    char* reader; 
    reader = malloc(sizeof(char)*1000); 
    int numHops; 
    while(fgets(reader,MAX_BUFFER ,file) !=NULL && cursor<Max_N) { 
    sscanf(reader, "%s %d", url, hoplimit); 
     numHops=0; 
     while (1) { 
      if (checkIndex(url, urlArray, Max_N)) { 
           indexMyStuff(url); 
       cursor++; 
      } 
      numHops++; 
      if(numHops<=*hoplimit && cursor<Max_N) { 

       if (!getLink(url,url,MAX_BUFFER)) { 
        break; 
       } 

      } else { 
       break; 
      } 
     } 
    } 


    free(url); 
    free(hoplimit); 
    free(reader); 
    fclose(file); 
    return urlArray; 
    } 




    //--------------------Header FILE for IndexPage------------------------// 
    #ifndef INDEX_H 
    #define INDEX_H 
    #include <stdlib.h> 
    #include <stdio.h> 
    #include <string.h> 
    #include <ctype.h> 

    struct wordControl{ 
     char** words; 
     int* countArry; 
    }; 
    typedef struct wordControl queryHelper; 
    queryHelper *indexMyStuff(char* argv); 
    #endif 

回答

1

這是用於獲得AP的大小不正確的語法ointer爲struct

sizeof(struct *wordControl) 
//   ^
// There should be no asterisk between struct keyword and the tag 

星號去的類型名稱後,不是struct和標籤之間:

sizeof(struct wordControl*) 
相關問題