Can I initialize string after declaration?

c

Solution

You can, but keep in mind that with that statements you are storing in `s` a pointer to a read-only string allocated elsewhere. Any attempt to modify it will result in undefined behavior (i.e., on some compilers it may work, but often will just crash). That's why usually you use a `const char *` for that thing.

Problem

Can I initialize string after declaration? ``` char *s; s = "test"; ``` instead of ``` char *s = "test"; ```

Original source