Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single line comments in Ansi-C

Tags:

c

gcc

I'm used to // to mark a single line comment from Java and Visual Studio and was surprised that this does not exist for Ansi-C. Using /* my comment */is quite annoying. Is there any other way to mark a single line comment when using Ansi-C?

like image 528
mort Avatar asked Nov 27 '11 10:11

mort


People also ask

How do you comment in ANSI C?

There are two ways to add comments in C: // - Single Line Comment. /*... */ - Multi-line Comment.

How do you comment out a single line in C?

Single-line comments start with two forward slashes ( // ). Any text between // and the end of the line is ignored by the compiler (will not be executed).

What are single line comments?

Single-line comments allow narrative on only one line at a time. Single-line comments can begin in any column of a given line and end at a new line or carriage return. The // character sequence marks the text following it as a single-line comment.

What is comment line in C programming?

A comment starts with a slash asterisk /* and ends with a asterisk slash */ and can be anywhere in your program. Comments can span several lines within your C program. Comments are typically added directly above the related C source code.


1 Answers

ANSI-C, no, but the current standard revision allows them, and has done so ever since C99.

like image 55
Brett Hale Avatar answered Oct 08 '22 04:10

Brett Hale