Weird Output when I compile?

This is a discussion on Weird Output when I compile? within the C++ Programming forums, part of the General Programming Boards category; HOw come I am getting some weird output when I go and compile it?
Code:
int main()
{
char c, ...

BTW, word1[i]='\0' is wrong. The string type starts empty. You cannot access any characters of an empty string. This might lead to a crash, or weird output or just an incorrect answer some of the time. If you want to add a space to the string, use +=. Also, the C++ string class doesn't have a null terminator. It doesn't need one because it keeps track of its own length. You'll have to rethink some of the code you are using so that it works with the C++ string class.

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell