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 6:22

>>2
>demented indentation
maybe I'll pretty it up next time faggot
>C++ infected
wat, there's nothing C++ here
>trivial problem explain in K&R
And here I am inspired by the K&R to write this, except no, they don't explain it.
>2.4
>All variables must be declared before use
>no explanation other than down the page "undefined values are bad"
>and the program still compiles and runs anyway

>>3
Indeed it does end, is it that it just takes so long to increment from -1/2 the size value to positive 256, and of course, that the system initializes the value at -1/2size instead of 0?

>>4
I guess I kind of explained my idea in 3.

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