Why the garbage value is same for all variables?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shubhangi24
    New Member
    • Oct 2012
    • 20

    Why the garbage value is same for all variables?

    please see the following code...

    why the garbage value for all the variables is same for same data type?


    Code:
    #include<stdio.h>
    int main()
    {
      int a,b,c;
      float f1,f2;
     
    
      printf("a=%d\nb=%d\nc=%d\nf1=%f\nf2=%f\n",a,b,c,f1,f2);
    
    return 0;
    }
    o/p:-

    a=-858993460
    b=-858993460
    c=-858993460
    f1=-107374176.00000 0
    f2=-107374176.00000 0
    Last edited by Rabbit; Apr 22 '13, 04:03 PM. Reason: Please use code tags when posting code.
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    this is your debug mode value, go to release mode it will be changed to something else

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      In the case of Visual Studio, the same garbage value is used for all variables. This is how the debugger can tell you that a variable you are using has not been initialized.

      Other compilers don't do this and it is not required that they do.

      Comment

      Working...