Different sizes of same strings - Telnet programming
Posted
by
tommyogp
on Stack Overflow
See other posts from Stack Overflow
or by tommyogp
Published on 2010-12-26T07:42:10Z
Indexed on
2010/12/26
7:54 UTC
Read the original article
Hit count: 143
Hi all, I have been trying to create an iphone app sending telnet command. However what puzzling me is that the sizes of certain strings are so much different, particularly when they include \n or \r. I listed out a few examples. Please assist.
const char *a = "play 25\n";
int sizeBitA1 = sizeof(a); // 8 units
int sizeBitA2 = sizeof("play 25\n"); // 9 units
const char *b = "\r\n";
int sizeBitB1 = sizeof(b); // 8 units
int sizeBitB2 = sizeof("\r\n"); // 3 units
© Stack Overflow or respective owner