小编Jos*_*ges的帖子

错误:标签只能是声明的一部分

我正在用C语言编写一个brainfuck解释器,我在使用一些我不习惯的东西时遇到了一些麻烦.在brainfuck中,逗号(,)本质上是getchar().所以我有以下代码:

//This is just ptr
static char *ptr;

switch (command)
{
  case ',':
    *ptr=getchar(); // Here's the code causing error
    break;
}
Run Code Online (Sandbox Code Playgroud)

error: a label can only be part of a statement and a declaration is not a statement当我尝试编译时,gcc会抛向我.

有任何想法吗?(对不起,不太熟悉这个错误)

c gcc pointers compiler-errors getchar

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

标签 统计

c ×1

compiler-errors ×1

gcc ×1

getchar ×1

pointers ×1