1
我有一個main
功能作爲一個更大的項目,是作爲其一部分的兩個或更多的數據類型如下:錯誤:在主聲明符()
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "header2.h"
int
main(int argc, char *argv[]) {
node_t *tst=NULL;
int weight;
char prefix[CHARMAX];
FILE *datafile = fopen(argv[1],"r");
while (fscanf(datafile,"%d;%[^\n]", &weight, prefix)==2) {
tst=insert(tst,prefix,weight);
}
fclose(datafile);
while (fscanf(stdin,"%s",prefix)) {
printf("Prefix: %s ",prefix);
FILE *out = fopen(argv[2],"a");
fprintf(out,"Prefix: %s\n",prefix);
fclose(out);
find_and_traverse(tst,(char*)prefix);
}
return 0;
}
我編譯我的生成文件的一部分,並得到這個錯誤:
stage2.c:2:1: error: two or more data types in declaration specifiers
int main(int argc, char *argv[]) {
^
線2包括<stdlib.h>
,所以我真的不知道是什麼原因造成這個錯誤。
關於header2.h
內容 - 考慮到誤差指着2號線不就行了4我不認爲這是必要的 - 但在這裏它是:
typedef struct node {
char data;
unsigned end_of_string: TRUE;
struct node *left;
struct node *equal;
struct node *right;
int weight;
} node_t;
typedef struct sorted_node {
char data[250];
int weight;
} sorted_node_t;
node_t* insert(node_t* pNode, char* word, int weight);
void find_and_traverse(node_t* pNode, char* prefix);
void selectionsort(node_t* pNode, char* buffer, int depth, int max);
void sort(sorted_node_t arr[], int n);
請幫幫忙!
所以你明白'header2.h'的內容可以引起這個,但是不要在你的問題中包含它們。當然你可以看到這個問題有多難以回答? – hvd
@hvd添加了header2.h文件。由於錯誤指向第2行而不是4,我認爲這不是必需的 – vulcanoiding
我不確定''unsigned end_of_string:TRUE;''typedef''是否正確。請刪除':TRUE'並重試。 –