Ocupa mƔs memoria el caracter 'a' que el string "a"? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

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

21st Apr 2018, 4:10 AM
SebastiƔn J. Tosco
4 Respostas
+ 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