How to create a string-type variable in C

后端 未结 8 1485
没有蜡笔的小新
没有蜡笔的小新 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 09:05

    C does not have a string variable type. Strings can be stored as character arrays (char variable type). The most basic example I would add up to the rest is:

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

提交回复
热议问题