#Strings
17 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
char hello[5] = "hello"; // does not contain '\0'
char hello[6] = "hello"; // does contain '\0'
char hello[] = "hello"; // does contain '\0'
const char *hello = "hello"; // does contain '\0'
Whenever you use the string notation (quotation marks) then a bull t terminating byte is automatically appended.
If you use array notation then you need to manually append the newline.
So
char s[] = "ab";
``` is the same as:
```c
char s[] = { 'a', 'b', '\0' };
The first line compiles?! 
char hello[5] = "hello";
It does T_T
<source>: In function 'main':
<source>:3:6: error: unused variable 'hello' [-Werror=unused-variable]
3 | char hello[5] = "hello";
| ^~~~~
cc1: all warnings being treated as errors
Build failed
<source>:3:6: error: unused variable 'hello' [-Werror,-Wunused-variable]
char hello[5] = "hello";
^
1 error generated.
Build failed
Neither GCC nor clang warn on it
They do however, if the array is even smaller - surprisingly it's still valid
sometimes you want a non null terminated blob.
tbh this really isn't the way to do it... but 
okkay tyvm !
okay thank u vm !
@vale minnow Has your question been resolved? If so, run !solved :)
!solved