Thread: Global variables question(very simple)

  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, 09:59 AM
  2. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 12: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, 12: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