I'm using codeblocks to learn C programming.
When I use /* */ the program works, but when I use // the program returns this error.
expected identifier or ‘(’ before ‘/’ token|
here's the 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;
}
From wiki:
C++ style line comments start with // and extend to the end of the line. This style of comment originated in BCPL and became valid C syntax in C99; it is not available in the original K&R C nor in ANSI C:
If you use gcc compiler, then add -std=c99 compiler argument.
It will enables C99 features, like // comments.
If you have -ansi option, then remove it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With