Auto variable initialization

This is a discussion on Auto variable initialization within the C Programming forums, part of the General Programming Boards category; I was experimenting in auto-variable initialization (eg int k; ) and I found out that : --On most windows machines ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    1

    Auto variable initialization

    I was experimenting in auto-variable initialization (eg int k; ) and I found out that :

    --On most windows machines ints are not auto-initialized to 0
    but
    on some linux machines ints are auto-initialized to 0.

    Is there any standard (C89 / C99?) which specifies the behavior of the following program or it is undefined?

    Code:
    int main (){
     int k;
     printf("%d",k);
    }
    Thanks in advance.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    It is defined that they are not required to be initialized.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  2. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 08:32 AM
  3. Problem with a char variable set as a letter
    By 7smurfs in forum C++ Programming
    Replies: 6
    Last Post: 12-10-2004, 12:25 PM
  4. Need help
    By awkeller in forum C Programming
    Replies: 2
    Last Post: 12-09-2001, 02:02 PM
  5. Variable Allocation in a simple operating system
    By awkeller in forum C Programming
    Replies: 1
    Last Post: 12-08-2001, 01:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21