Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 709949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:33:37+00:00 2026-05-14T04:33:37+00:00

If I have a global static variable x like in this code #include <stdio.h>

  • 0

If I have a global static variable x like in this code

 #include <stdio.h>
 #include <stdio.h>

 static int x;

 int main(void)
 {

 DO SOMETHING WITH x HERE

 x++;

 }

What will be difference if I opted to initialize x to a value first say as in

static int x = 0;  

before entering “main”?

In my first case where I didn’t assign a value to x, does the compiler implicitly know that x is to be set to zero as it’s a static variable? I heard that we can do this with static variables.

Thanks a lot…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:33:38+00:00Added an answer on May 14, 2026 at 4:33 am

    There is a nice answer here:

    Just a short excerpt:

    First of all in ISO C (ANSI C), all static and global variables must be initialized before the program starts. If the programmer didn’t do this explicitly, then the compiler must set them to zero. If the compiler doesn’t do this, it doesn’t follow ISO C. Exactly how the variables are initialized is however unspecified by the standard.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 532k
  • Answers 532k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Multi-line fields (such as Keywords) simply expect a carriage return… May 17, 2026 at 12:12 am
  • Editorial Team
    Editorial Team added an answer It's better to use parameterized sql queries, instead of building… May 17, 2026 at 12:12 am
  • Editorial Team
    Editorial Team added an answer I think Adapter isn't a good place to add list… May 17, 2026 at 12:12 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

which is the cleanest way to use something like a global variable? Normally, using
I have a C++ code that's a physics simulation tool. I would like to
I have implemented a very basic plug-in system as part of a static library
I'm exploiting the behavior of the constructors of C++ global variables to run code
I have some code (which I cannot change) that I need to get working
I have two source files that need to access a common variable. What is
This might be a dumb question, but maybe someone can provide some insight. I
I am writing a large C program for embedded use. Every module in this
I have a SQL script that inserts data (via INSERT statements currently numbering in
I have an IronPython script that uses the TPL and Parallel.ForEach to process files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.