I have such code:
char str1[100] = "Hel0lo";
char *p;
for (p = str1; *p != 0; p++) {
cout << *p << endl;
/* skip along till the end */
}
and there are some parts not clear for me.
I understand that null-terminated string at memory is byte with all bits equal to 0 (ASCII). That's why when *p != 0
we decide that we found the end of the string. If I would like to search till zero char, I should compare with 48, which is DEC
representation of 0 according to ASCII at memory.
But why while access to memory we use HEX
numbers and for comparison we use DEC
numbers?
Is it possible to compare "\0"
as the end of string? Something like this(not working):
for (p = str1; *p != "\0"; p++) {
And as I understand "\48"
is equal to 0
?