473,397 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Where does the uninitialized pointer point ?

I am just having one confusion that if I do not initialize the pointer and if I print its value then how come it prints some random location , how is this random location calculated and each time I run my code it remains same , whats the reason behind this ?
Jun 28 '15 #1
3 1463
weaknessforcats
9,208 Expert Mod 8TB
What can I say? The entire computer memory consists of bits. You create a pointer and you get ownership of some of these bits. What's the value? Could be anything. Could it be from a previous run of your program? Why not?

Don't waste time trying to figure out why you get an indeterminate result.

You must absolutely initialize a pointer to a known value before you use it.
Jun 28 '15 #2
Sir I am having just one confusion that why does this random address printed all and over again similarly , although compiler generates logical addresses but still regarding this random location , its just run time so then how is this value printed every time same only ?
Jun 28 '15 #3
weaknessforcats
9,208 Expert Mod 8TB
Do you know your compiler allocates memory? Unless you put an address you know in that pointer, the contents of the point are meaningless.

In other words, values you didn't place in your variables are garbage values. By any chance are you using Visual Studio? That compiler places a value in all of your pointers that it can use to tell if the pointer has not been initialized. So even though this compiler sees that value as known (since it put it there), to you, it is a garbage value.
Jun 28 '15 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: patrick.m.lahey | last post by:
Newbie here... Ok, the following code: class Base: _count = 0 def __init__(self): self.__class__._count += 1 print dir(self)
2
by: google | last post by:
The DBA duties at my company have gotten to the point where I am unable to complete them all on my own so we decided to hire a new DBA. After weeks of searching and interviewing we are coming up...
0
by: sachin | last post by:
When we view any document in print preview dialog, where does it save the document? such that when me move to next/previous page where it reads the information from . If a heavy document like RTF...
2
by: Sean | last post by:
Hi all, I know that some variables are stored on heaps and some on stack in C++. How about functions? where does function reside on memory? Is it stack or heap? And are both function (not...
1
by: Daniel | last post by:
where does Microsoft.Xml.Xquery live? where does Microsoft.Xml.Xquery live? all i can find is a copy of it in the sample project:...
4
by: qazmlp1209 | last post by:
Is the following code reliable? I'm wondering whether it is valid to invoke the static function using uninitialized pointer. ----------------- #include <iostream> class staticCl { public:...
5
by: Niu Xiao | last post by:
I saw a lot of codes like: void foo(void* arg) void bar(void** arg) f((void*)p) but what does void pointer mean in c? I just know it stands for generic pointer. thanks.
15
by: amit.man | last post by:
Hi, i have newbie qestion, when i write #include <somthing.h> the precompiler subtitue that line with the lines from "somthing.h" header file. when, where and how the compiler insert the...
0
by: sanchaita | last post by:
I wanted to know where does the WPHOST.db file corresponding to the post office in a novell groupwise gets stored. Does it get stored in our local disc. If yes, then where?. And where does the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.