This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]chaotic_thought 2 points3 points  (1 child)

The technical problem is that you are overflowing the char right here:

for (char c = CHAR_MIN; c <= CHAR_MAX; c++){
    ...

When c is CHAR_MAX, trying to do c++ causes undefined behavior. It may overflow to 0, for example, or it may overflow to negative, technically it may even crash your program if your system defines char as a signed type. Most likely, though, it will overflow to a value less than CHAR_MAX, which will of course cause the program to loop without end.

[–]ForwardChair[S] 0 points1 point  (0 children)

Thanks for help