How to create a string-type variable in C

后端 未结 8 1368
没有蜡笔的小新
没有蜡笔的小新 2021-02-04 08:42

Question

How to declare a string variable in C?

Background

In my quest to learn the basics of c, I am trying to port on

8条回答
  •  无人及你
    2021-02-04 08:59

    char name[60];
    scanf("%s", name);
    

    Edit: restricted input length to 59 characters (plus terminating 0):

    char name[60];
    scanf("%59s", name);
    

提交回复
热议问题