Output the first character of a string in the C language.
#include <stdio.h>
int main() {
char str[] = "Hello, World!";
printf("The first character of the string is: %c\n", str[0]);
return 0;
}
In this C code snippet, we define a string ‘str’ and then use the printf() function to output the first character of that string. In C language, strings are stored as arrays of characters, and specific characters in the string can be accessed by specifying an index. Therefore, str[0] represents the first character of the string ‘str’.