+ 1

Ocupa más memoria el caracter 'a' que el string "a"?

21st Apr 2018, 4:10 AM
Sebastián J. Tosco
4 Réponses
+ 3
strings manage char arrays for you. That's all they're doing.
21st Apr 2018, 9:58 PM
Timon Paßlick
0
SIP. Por ser un puntero a char... Probé ejemplo y uno ocupa 1 Byte y el otro 4. Gracias
21st Apr 2018, 4:33 AM
Sebastián J. Tosco
0
sizeof("a") is 2 instead of 1. That's because of the '\0' character which terminates string literals in memory. Note that "a" is a char[2] and not a char*.
21st Apr 2018, 7:01 AM
Timon Paßlick
0
Thanks Timon. But i have a dude. https://stackoverflow.com/questions/1287306/difference-between-string-and-char-types-in-c strings are not char array, right? Are a class related with array but asigned like a pointer? 😕😑 I am confused. Thanks in advance...
21st Apr 2018, 8:41 PM
Sebastián J. Tosco