Hello all,
I am confused with the Output of the Following Program which is mentioned below.

int main( )
{
        int c = 10;
        printf(c);
}

The Output here is segmentation Fault when i compiled the program with gcc-4.1.2

The Same program when i remove the initialization of c & compile it the Junk value is been printed.

int main( )
{
        int c;// = 10;
        printf((int *)c);
}

Output : U��WVS�Py

Can anyone explain why is it so..

Thanks
With Regards

Do you think your have a virus???
What problems are you having???
What program did you use???

Thanks,

Cohen

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.