c - 在 C 中编译 Lisp 解释器时收到警告

标签 c

在尝试编译解释器时,我不断收到使用 gets() 警告,并且终端中没有任何输出。我也将 gets() 更改为 fgets() 但它仍然不输出任何内容并给我一个错误:

$ ./littleLisp 
warning: this program uses gets(), which is unsafe.
5.000000
littleLisp.c:16:18: error: too few arguments to function call, expected 3, have 1
        while (fgets(str) && strcmp(str, "")) {
               ~~~~~    ^
/usr/include/stdio.h:238:1: note: 'fgets' declared here
char    *fgets(char * __restrict, int, FILE *);
^
1 error generated.
make: *** [littleLisp] Error 1
$ make littleLisp
cc     littleLisp.c   -o littleLisp
littleLisp.c:16:18: error: too few arguments to function call, expected 3, have 1
        while (fgets(str) && strcmp(str, "")) {
               ~~~~~    ^
/usr/include/stdio.h:238:1: note: 'fgets' declared here
char    *fgets(char * __restrict, int, FILE *);
^
1 error generated.
make: *** [littleLisp] Error 1

知道发生了什么吗?

要点如下:

https://gist.github.com/rahul1346/8596118b834ecf41b1d9

最佳答案

根据 man page fgets() 的语法为

char *fgets(char *s, int size, FILE *stream);

因此,对 fgets() 的调用需要具有三个参数。

在您的代码中,while (fgets(str).....,它只有一个。

关于c - 在 C 中编译 Lisp 解释器时收到警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28179315/

相关文章:

c - 从 'const char*' 到 'char' 的无效转换 [-fpermissive]

c - strncpy 和 memcpy 之间的区别?

c - 正确的 FIFO 客户端-服务器连接

c语言+二维数组

c - C 语言中 inet_aton() 和 gethostbyname() 的区别?

c - 无法将元素插入链表

c - 解析十六进制文件并将其拆分为 6 位整数

php - 构建 PHP 扩展并使用 call_user_function

c - 编写一个二进制搜索方法,在数组中找到一个单词时努力返回 1(真)。 [家庭作业}

c++ - 剥离符号的最佳方法