How do you input strings in the C programming language?

In the C programming language, you can use the scanf function to input a string. Here is an example code:

#include <stdio.h>

int main() {
    char str[100];
    
    printf("请输入字符串:");
    scanf("%s", str);
    
    printf("输入的字符串是:%s\n", str);
    
    return 0;
}

In the above code, the scanf function is used to input a string and %s is used as the format string. The inputted string will be stored in the str array.

bannerAds