出于某种原因,我收到错误:
expected identifier or '(' before 'wordlist'
在我的头文件(以及相应的函数定义)中,这两个函数返回 wordlist
指针。
使用以下代码:
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
typedef struct word{
char *string;
struct word* next;
}word;
typedef struct wordlist{
word *head;
word *tail;
}wordlist;
*wordlist populateList(FILE *file);
*wordlist encrypt(wordlist *wl, int rotation);
void toFile(wordlist *wl, char *outputFileName);
#endif
谁能告诉我为什么会这样?
最佳答案
这是因为当你声明一个指针时,星号必须跟在类型名之后,而不是在它之前:
wordlist * populateList(FILE *file);
// ^
// |
// Here
关于c - C 中的预期标识符错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15869957/