473,385 Members | 2,069 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,385 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 1462
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.