0

struct start
{
int* i;
int* j;
}p;

p.i = new getValue();

when i am printing the value of i it is giving address not the value. Please tell how to get the value.

6
Contributors
5
Replies
7
Views
7 Years
Discussion Span
Last Post by jephthah
1

surely it will give you the address because int *i; is a pointer int variable
where i holds the address you should study pointers deeply before using it with structures.
use *(p.i) it will work but it is not a right way to learn language pointers are the most difficult topic in c language so don't take it easily.

1

pointers are the most difficult topic in c language so don't take it easily

Pointers are only the most difficult topic because people like you brainwash beginners into believing they're difficult. Pointers are in reality very simple.

0


p.i = new getValue();

While I am sure your question must have been answered already, I am interested to know what does new getValue() do.

1

i too was wondering that. and where does *i and *j get allocated.

but I'm also kind of afraid to ask. may be best to leave well enough alone.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.