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

  • Home
  • SEARCH
  • 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 6821727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:34:43+00:00 2026-05-26T21:34:43+00:00

I was asked this question in an interview. If there is a pointer that

  • 0

I was asked this question in an interview.

If there is a pointer that is declared but not initialized like this:
int *ptr;

Is it assigned a default value? Or will it be a null pointer? Also, what happens if we try to use this pointer like:

if(ptr)
{
//block of code
}

Will the if condition pass? Also, will this work on debug/release build?

I tried to run this program at home and found that if condition passes, and if I try to print the value of the ptr like this:

printf("%x %d", ptr, *ptr);

it prints some random value, but it doesn’t crash the program. What is the explanation behind this?

  • 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-26T21:34:44+00:00Added an answer on May 26, 2026 at 9:34 pm

    Uninitialized pointers are good for security vulnerabilities and possibly contributing to seeding random number generators.

    Your if condition will only skip the block of code if the pointer had been initialized to NULL (0).

    Because the initialization value is undefined by default it is always considered good practice to initialize to NULL.

    Your printf statement just illustrates the fact that it defaulted to a value other than NULL and in this case it was a valid area of memory that could be dereferenced.

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

Sidebar

Related Questions

In an interview they had asked an Question like this there are three overloading
I hope that this question has not been asked elsewhere, but I'm having difficulty
Yesterday in my interview I was asked this question. (At that time I was
I was asked this question in a job interview, and I'd like to know
This is a question that I was asked on a job interview some time
I was recently asked this question in an interview: There are two arrays of
I have been asked this question today. When debugging, there is an error. But
I was recently asked this question in one of my telephonic interview. There is
So in an interview, I was actually asked a simple question that goes like
I was asked this question in an interview, but I couldn't come up with

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.