+ 1

Why C strings are declared char * ?

Why can I work with it as char * str = "Some string"? Shouldn't it receive a char memory space? Recently declared pointers aren't dangling? Isn't it dangerous to just push things into RAM? Aren't char pointers meant to hold an 8 bit place? Please be descriptive at maximum, i already make this question to many people and I couldn't understand very well. Hope you can help me. Thank you =)

6th Apr 2017, 12:38 PM
JoĂŁo Krejci
JoĂŁo Krejci - avatar
1 Answer
+ 1
Strings in C are actually arrays of char type. And as with any array, you can address to the initial item thru the * operator.
6th Apr 2017, 1:13 PM
Álvaro