Why do we need strdup()?

前端 未结 5 1895
花落未央
花落未央 2021-02-20 07:24

While I was working on an assignment, I came to know that we should not use assignments such as :

 char *s=\"HELLO WORLD\";

Programs using such

5条回答
  •  耶瑟儿~
    2021-02-20 08:27

    Read my answer on (array & string) Difference between Java and C. It contains the answer to your question in the section about strings.

    You need to understand that there's a difference between static and memory allocation and that you don't resort to the same memory spaces.

提交回复
热议问题