Reputation: 1519
When I code and run the statement:
print "\x00\x00\x00"
in Python it outputs three blank spaces followed by a newline. But in C, when I code and run the statement:
char hex[] = "\x00\x00\x00";
printf("%s\n", hex);
it interprets the NULL bytes like I thought it would: it doesn't do anything. So why in Python are NULL bytes treated as spaces?...
Upvotes: 3
Views: 16119
Reputation: 799100
So why in Python are NULL bytes treated as spaces?
It's not. Your terminal/console is treating them like spaces. C just happens to stop at the first NUL, whereas Python outputs them. Try writing three NULs to stdout instead.
Upvotes: 10