954,206 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Problem About Pointers

1.
int *f()
{
int *m=(int *)malloc(2);
return m;
}
WHY THIS POINTER TO INT TREATED AS A GLOBAL VARIABLE.
2.can a pointer points to another pointer
like that
int *p,i=2;
int *q;
p=&i;
q=p;
IS IT RIGHT.

Sukhbir
Light Poster
31 posts since Jul 2004
Reputation Points: 11
Solved Threads: 0
 

about the second question yes you can use pointer to refrence to another pointer and this is the method used in dynamic allocation of multi dimintion aray you can write :
void a2d(int i,int j)
{
int **t =new int*[i] ;//rows
for(int k=0;k

stg110
Newbie Poster
11 posts since Aug 2004
Reputation Points: 11
Solved Threads: 0
 

there can be pointer to pointer.
int a=25;
int*b=&a;
int**c=&b;

let us c
Newbie Poster
17 posts since Aug 2004
Reputation Points: 10
Solved Threads: 1
 

there can be pointer to pointer.
.............
int a=25;
int*b=&a;
int**c=&b;
............
here c is pointer to b.

let us c
Newbie Poster
17 posts since Aug 2004
Reputation Points: 10
Solved Threads: 1
 

there can be pointer to pointer.
.............
int a=25;
int*b=&a;
int**c=&b;
............
here c is pointer to b and b is pointer to a.
value of acan be accesed in two ways.ie by both the pointers.


if i am wrong anywhere please tell me.thank you :p

let us c
Newbie Poster
17 posts since Aug 2004
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You