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.

printf("%d\n", *p.i); You have to use the * operator to print the value that i points to.

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.

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.


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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.