Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Why doesn't this end

Name: Anonymous 2010-10-31 5:35

#include <stdio.h>

main()
{

    int a;

while(a != 256)
    {putchar(a);
    a++;}
}

But if I add  a = 0;  after int a;, it ends fine?

Something to do with a variable not being initialized properly, and therefore, not being able to be compared or something?

Compiled with Code::Blocks+GCC or mingw or something. The debugger also reports no relevant issues with the initial code.

Name: Anonymous 2010-10-31 7:57

>>16

This still does not mean he can't use an int.

The true error lies in the lack of initialization, not in the usage of int instead of char.

Hell, you can use:

time_t t;
for (t=0;t<256;++t) { putchar((char)t); }


if you wish.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List