The rules that dictate the correct format of code for a specific programming language are known as syntax.
Examples of syntax in C are:
When compiling C code, an error will occur when the syntax of the code is incorrect.
// Statements must end in a semicolon (;)// correctprintf("Hello World!");// errorprintf("Hello World!")// Code elements are case sensitive// correctprintf("Hello World!");// errorPRINTF("Hello World!");
In C, an escape sequence is a non-visual character used within a string.
\n is an escape sequence that adds a newline to a string.
\t is an escape sequence that adds a tab of spaces to a string.
// \n acts as a newline in a stringprintf("Hello\nWorld!"); // Outputs: Hello// World!// \t acts as a tab in a stringprintf("Hello\tWorld!"); // Outputs: Hello World!
In C, comments are text within code that will be ignored by the compiler. They are used to document code.
Line comments begin with a double forward slash,
//. All text after
// will be part of the comment until a new line is reached.
Block comments begin with a forward slash and asterisk,
/* and end with an asterisk and forward slash,
*/. Block comments can span multiple lines as new lines are part of the comment.
// Comments/* This review content isabout comments and how theycan be used to document code */// This is a line comment/* This is ablock comment */
gcc is an application used to compile C programs into an executable that can run on the target computer.
gcc stands for GNU Compiler Collection.
gcc compiles C code using the code file as an unflagged command-line argument. The output executable file will be called
-o flag followed by some text can be used to designate the name of the output executable file.
gcc script.cgcc script.c -o myProgram