Global variables question(very simple)

This is a discussion on Global variables question(very simple) within the C++ Programming forums, part of the General Programming Boards category; Are global variables automatically declared as static and initialized to 0? What ANSI says about this? Thanks for any answer!...

  1. #1
    Disturbed Boy gustavosserra's Avatar
    Join Date
    Apr 2003
    Posts
    244

    Global variables question(very simple)

    Are global variables automatically declared as static and initialized to 0? What ANSI says about this?

    Thanks for any answer!
    Nothing more to tell about me...
    Happy day =)

  2. #2
    Open to suggestions Brighteyes's Avatar
    Join Date
    Mar 2003
    Posts
    204
    >Are global variables automatically declared as static and initialized to 0?
    If by global variable you mean this:
    Code:
    int a; // Global
    
    int main()
    {
        ...
    }
    Then yes, the standard guarantees that a will have static linkage and be initialized to 0.
    p.s. What the alphabet would look like without q and r.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 08-06-2008, 10:59 AM
  2. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 01:17 AM
  3. Global variables used in a linked class, getting errors.
    By RealityFusion in forum C++ Programming
    Replies: 3
    Last Post: 09-24-2005, 01:25 AM
  4. Global variables.. how bad?
    By punkrockguy318 in forum C++ Programming
    Replies: 19
    Last Post: 11-30-2003, 10:53 PM
  5. GLobal variables
    By fuh in forum C++ Programming
    Replies: 21
    Last Post: 01-01-2003, 03:11 AM

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