小编kat*_*iea的帖子

链接列表和指针语法错误

此程序只需使用ASCII行文件,将其放入链接列表堆栈,然后将反转列表打印为相同ASCII格式的新文件.

我的结构代码:

typedef struct Node{
    char info[15];
    struct Node *ptr;
};
Run Code Online (Sandbox Code Playgroud)

我在Main上遇到以下错误.大多数人都必须在我声明新节点头的地方做...那个语法出了什么问题?:

Errors
    strrev.c:28: error: ‘Node’ undeclared (first use in this function)
    strrev.c:28: error: (Each undeclared identifier is reported only once
    strrev.c:28: error: for each function it appears in.)
    strrev.c:28: error: ‘head’ undeclared (first use in this function)
    strrev.c:34: warning: passing argument 1 of ‘strcpy’ from incompatible pointer type
   /usr/include/string.h:128: note: expected ‘char * __restrict__’ but argument is of         type ‘char **’
Run Code Online (Sandbox Code Playgroud)

主要代码:

int main(int argc, char *argv[])
{
    if …
Run Code Online (Sandbox Code Playgroud)

c syntax struct pointers

2
推荐指数
1
解决办法
716
查看次数

让文件无效?

找到解决方案 见下文:

我正在尝试让我的makefile将三个c程序编译成一个可执行文件,但是我收到以下错误:

cachesim.o: could not read symbols: File in wrong format
Run Code Online (Sandbox Code Playgroud)

是的,我每次使用时都会使用make clean.make文件如下

CC     = gcc
CFLAGS = -Wall -m32 -O -g

all:  cachesim cache trace_file_parser 
gcc -o cachesim cachesim.o cache.o trace_file_parser.o

cachesim:       cachesim.c
        $(CC) -c -o cachesim.o cachesim.c $(CFLAGS)

cache:          cache.c
        $(CC) -c -o cache.o cache.c $(CFLAGS)

trace_file_parser:  trace_file_parser.c
        $(CC) -c -o trace_file_parser.o trace_file_parser.c $(CFLAGS)

clean:
rm -f *.o
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚为什么这是....

我每次都在使用make clean.

试图编译:

[katiea@mumble-15] (34)$ make clean
rm -f *.o
[katiea@mumble-15] (35)$ ls
cache.c   cache.h     cachesim.c~      gcc_trace  Makefile~ …
Run Code Online (Sandbox Code Playgroud)

compiler-construction executable gcc makefile

2
推荐指数
1
解决办法
1万
查看次数

学习C,并获得错误(我认为主要是语法,但我正在学习!)

此程序只需使用ASCII行文件,将其放入链接列表堆栈,然后将反转列表打印为相同ASCII格式的新文件.

我的结构代码:

typedef struct Node{
char *info[15];
struct Node *ptr;
};
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

Errors:
    strrev.c:14: warning: useless storage class specifier in empty declaration
    strrev.c: In function ‘main’:
    strrev.c:28: error: ‘Node’ undeclared (first use in this function)
    strrev.c:28: error: (Each undeclared identifier is reported only once
    strrev.c:28: error: for each function it appears in.)
    strrev.c:28: error: ‘head’ undeclared (first use in this function)
    strrev.c:34: warning: passing argument 1 of ‘strcpy’ from incompatible pointer type
Run Code Online (Sandbox Code Playgroud)

/usr/include/string.h:128:注意:预期'char*restrict '但参数类型为'char**'

我的主要计划:

int main(int argc, char …
Run Code Online (Sandbox Code Playgroud)

c syntax struct

0
推荐指数
1
解决办法
285
查看次数