Merge pull request #394 from unreal0901/patch-2

Added String literals
This commit is contained in:
Fechin authored and GitHub committed 2023-02-19 10:04:18 +08:00
commit 6fd62b4864
1 file changed
+8
+8
View File
@@ -185,6 +185,14 @@ printf("%s", greetings);
// print "Hell!"
```
Creating String using character pointer (String Literals)
```c
char *greetings = "Hello";
printf("%s", greetings);
// print "Hello!"
```
**NOTE**: String literals might be stored in read-only section of memory. Modifying a string literal invokes undefined behavior. You can't modify it.!
`C` **does not** have a String type, use `char` type and create an `array` of characters