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 9006807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:30:41+00:00 2026-06-16T01:30:41+00:00

Quick question, is it good practice to initialize all blank or empty variables when

  • 0

Quick question, is it good practice to initialize all “blank or empty” variables when it has not to carry either positive or negative values, for example using this:

int value = 0;

instead of:

int value;

I accept the Visual Studio compiler, from what I understand, automatically initializes variables to 0 by default if they are not initialized before hand but I am curious as to what the best practice is and what the potential hazards (if any) are.

Although I am referring to the C# and C++ languages within the VS environment particularly, this question is open to any languages and compilers across the spectrum.

  • 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-06-16T01:30:42+00:00Added an answer on June 16, 2026 at 1:30 am

    It is always good practice to initialize variables to prevent undefined behavior later in the program. Some later compilers might do this for you, but at the lower lever not defining a variable CANNOT be caught by the compiler and can lead to some very painful headaches. If you have a massive list of variable i usually use a big equals statement:

    int a,b,c,d,g;
    a=b=c=d=g=0; //set all to zero
    

    it’s apart of the bigger c++ philosophy to always have a value stored in your variable at all times .

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

Sidebar

Related Questions

I'm not good at Mysql expressions, so here is a quick question that I'm
Good day, just a quick question: I would like to bind a table to
Good afternoon, I have a quick 'top level' question regarding the usage of Facebook
Quick question, has anyone done a benchmark on random number generation between javascript and
Just a quick question, on which I cannot find a good reference, especially with
Good Morning, Just a quick question what this field actually means? I am trying
I am using EF4. Just a quick question, is this a really good framework?
Hopefully a quick question. I'm trying to validate a double. Making sure it's positive
Hey just a quick question for anyone who has done this. I want to
Quick question: is it a good idea to use sqlite while developing a Django

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.