char

comparing static char [] and const char *

static char a[255] = "\0"; and const char *b = " "; now when I assign "abc" to a and b, for a the remainig 252 bytes stay '\0' and for b its not like that. So, when I try to compare them, they come out to be different. One solution is to just compare till sizeof(b) as we do in strncmp(). Is there any other way of doing it? Probably b...

How to output unsigned/signed char or <cstdint> types as integers with << in C++

Background: I have template stream operators (e.g. operator << (ostream &, std::vector <T>)) (that output container elements that may possibly be of some 8-bit integer type, (e.g. unsigned char, int_least8_t, et cetera). Problem: Default is that these types are output as char (ASCII). I only used char (or wchar_t or whatever) for ASCI...

sizeof for a null terminated const char*

const char* a; how do I make sure that string 'a' is null terminated? when a = "abcd" and I do sizeof(a), I get 4. Does that mean its not null-terminated? if it were, I would have gotten 5 ? ...