*str : B
*str : C
*str : D
// ... blah
*str : Y
*str : Z // something's wrong below
*str :
*str : F
*str : o
*str : u
*str : n
*str : d
*str :
*str : '
*str : 2
Found '2' in ABCDEFHIJKLMNOPQRSTUVWXYZ
Because str will never be a null pointer (it would be if program would not encounter uninitialized memory and crash before str could overflow)
After you cheched whole string your program moves further in random memory. In your case it is where all string constant are stored (as you can see from output)
You possibly wanted to check if you encountered null symbol (end of string). in that case you should use while(*str != '\0') or just while(*str)