RE: pointers in c!

  • From: "Ken Perry" <whistler@xxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Fri, 26 Oct 2007 10:59:56 -0700

It could do just about anything because you did not initialize the pointer
to point at anything.  Not only that but you are in essence saying is the
memory location = to 6.  The pointer is probably pointing at something out
in the operating system though so your probably getting something like
58392==6 which is not what you want I am sure.  If you wanted to make this
block of code actually mean something you would have to write it like this

int y==4;
int *x=y;

if (*x=6)

This would say make an integer and set it to 4.  then Make a pointer called
x and point it at the integer y and thus the value of that pointers location
would now equal 4.  Then the if statement would fail because x is pointing
at 4 and when you put the * in front of x it dereferences the pointer to
give the value 4.

If that totally confused you, you might want to read another chapter on
pointers.  In fact I have found a good tutorial on pointers that start at
the basics and take you into arrays so check this out.    

For those reading this pointers is the defining feature of c and c++ if you
do not understand pointers you will never get good at the two languages.


-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Daniel Dalton
Sent: Friday, October 26, 2007 1:21 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: pointers in c!


Just learning about pointers in c.
Can someone explain the (x) operator to me? what is x?
what would this do?
int y =4;
int * x;
if((x) ==6)

Or do I need to learn something else?
I just don't understand this () stuff. I know how it is used for functions
and statements like if, for and while.
Could someone please help me out with this?
Daniel Dalton
View the list's information and change your settings at

View the list's information and change your settings at 

Other related posts: