相关疑难解决方法(0)

char s []和char*s有什么区别?

在C中,可以在声明中使用字符串文字,如下所示:

char s[] = "hello";
Run Code Online (Sandbox Code Playgroud)

或者像这样:

char *s = "hello";
Run Code Online (Sandbox Code Playgroud)

那么区别是什么呢?我想知道在编译和运行时的存储持续时间实际发生了什么.

c string constants char

495
推荐指数
6
解决办法
33万
查看次数

声明字符串和分配字符串之间的区别

I.  char *str = "Stack";

II. char *str = (char*) malloc(6);
    strcpy(str, "Stack");
Run Code Online (Sandbox Code Playgroud)

上述两种方法有何不同?

窗帘后面是相同还是不同?

c

5
推荐指数
1
解决办法
6942
查看次数

标签 统计

c ×2

char ×1

constants ×1

string ×1