c print string
To print a string in C, you can use the printf()
function. Here's the syntax:
#include <stdio.h>
int main() {
char str[] = "Hello, World!";
printf("%s", str);
return 0;
}
In this example, we include the <stdio.h>
header file which contains the printf()
function. We declare a character array str
and assign the string "Hello, World!" to it. Then, we use printf()
to print the string by using the %s
format specifier, followed by the variable str
.
When you run this code, it will output:
Hello, World!
You can replace the string "Hello, World!" with any other string you want to print.