Error: Unterminated comment (Invalid comment block) in C | Common C program Errors
Comments are used to write logic explain or anything that you do not want to compile. In C language there are two types of comments 1) Single line comment and 2) Multi-line comment.
#include <stdio.h>
int main(void) {
/*printf is used to print a message \*
printf("Hello world");
return 0;
}
Output
prog.c: In function ‘main’:
prog.c:5:5: error: unterminated comment
/*printf is used to print a message \*
^
prog.c:3:1: error: expected declaration or statement at end of input
int main(void) {
^~~
How to fix Unterminated comment error in C
Note that, multiple line comment are placed between /* and */, terminate the comment properly with valid characters.
Correct code
#include <stdio.h>
int main(void) {
/*printf is used to print a message*/
printf("Hello world");
return 0;
}
Consider the program:
Output
How to fix Unterminated comment error in C
Note that, multiple line comment are placed between /* and */, terminate the comment properly with valid characters.
Correct code
Output
need an explanation for this answer? contact us directly to get an explanation for this answer