无法在codeblocks上发表评论

Sam*_*NLP 2 c linux codeblocks

我正在使用代码块来学习C编程.

当我使用/* */该程序工作,但当我使用//该程序返回此错误.

expected identifier or ‘(’ before ‘/’ token|
Run Code Online (Sandbox Code Playgroud)

这是main.c

#include <stdio.h>
#include <stdlib.h>

//Ex1

int i;
float p;
char *n;

int main(void)
{
    i = 22;
    p = 70.0;
    n = "Samuel";

    printf("%s %d %.2f", n, i, p);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

小智 5

从维基:

C ++样式行注释以//开头,并扩展到该行的末尾。这种注释风格起源于BCPL,并在C99中成为有效的C语法。它在原始K&R C或ANSI C中均不可用:


SKi*_*SKi 5

如果使用gcc编译器,则添加-std=c99编译器参数.它将启用C99功能,如//评论.

如果您有-ansi选项,则将其删除.