Console writeline new line c
A simple one!
In C, you can use the printf
function to print a newline character to the console. Here are a few ways to do it:
- Using
\n
:#include <stdio.h>
int main() { printf("Hello, world!\n"); return 0; }
The `\n` character is an escape sequence that represents a newline.
2. Using `puts`:
```c
#include <stdio.h>
int main() {
puts("Hello, world!");
return 0;
}
The puts
function is similar to printf
, but it automatically appends a newline character to the end of the string.
- Using
fputs
:#include <stdio.h>
int main() { fputs("Hello, world!\n", stdout); return 0; }
The `fputs` function writes a string to the file stream `stdout`, which is the console by default. The `\n` character is included in the string.
All of these examples will print "Hello, world!" followed by a newline character to the console.