I want to print a dynamic char array which has \0 characters before the actual end.
I am printing it by using cout
for every index.
for (int i = 0; i < size; i++) {
std::cout << content[i];
}
But when I come by a \0 character I want to detect it, so I'm using:
if (content[i] == 0) {
std::cout "zero";
}
I tried to do
if (content[i] == "\0") {
std::cout "zero";
}
But I can't do that comparison because you apparently cannot compare a const char*
and a char
.
What did I do wrong? How do I make this comparison?
char
array btw:
char * content = new char[size];
file.seekg(0);
file.read(content, size);