C Programming/Basic Output
Objective[edit | edit source]
|
Lesson[edit | edit source]Output is information that the program tells the user. The most basic way to do this is writing text to the console. In the previous lesson, we output text to the console using the following program: #include <stdio.h>
int main(void)
{
printf("Hello world!\n\n");
printf("Press any key to continue ...");
getch();
return 0;
}
If you compile the above program and run it, you will get this output: The function [edit | edit source] |
Escape Sequence | Description |
---|---|
\' |
Single quote |
\" |
Double quote |
\\ |
Backslash |
\nnn |
Octal number (nnn)* |
\0 |
Null character (really just the octal number zero) |
\a |
Audible bell |
\b |
Backspace |
\f |
Formfeed |
\n |
Newline |
\r |
Carriage return |
\t |
Horizontal tab |
\v |
Vertical tab |
\xnnn |
Hexadecimal number (nnn)* |
* For both Hexadecimal and Octal number escape sequences, \nnn or \xnnn evaluates to a character with character code nnn. For example, \101 evaluates to the character A, as A has the character code of 101 in octal format.
Examples
[edit | edit source]Further reading
[edit | edit source]
Assignments[edit | edit source]
|