How can a string be output in the C language?

In C language, you can use the printf function to output a string. For example:

#include <stdio.h>

int main() {
    char str[] = "Hello, World!";
    printf("%s\n", str);
    return 0;
}

The output is:

Hello, World!

In printf function, %s is a format specifier used to output a string. It indicates that a string will be displayed, with the actual string being represented by the variable ‘str’.

bannerAds