include<iostream>
using namespace std;
void fun(char **p)// a pointer to a pointer , so that you receive the
address of the pointer so you can change it.
{
char *a="yet another";
*p=a; //Make the value of the pointer to the pointer (meaning the value
of
the pointer sent, the address itself) equal to a.
}
main()
{
char *p="hellow world";
fun(&p); //send the address of the pointer.
cout<<p;
system("pause" );
}
I was expecting output is "yet another". but I got "hellow world".
my question is in the function void fuc(.....) is there any difference
between *p=a or p=&a
the second question is
in case of single pointer
example
int *p;
*p=2;
is this correct way of assigning 2 or is it wrong.........wat i think is
a pointer can hold a memory adress only ............so the above code
must be like this
int *p;
int a=3;
p=&a;
m i right......or wrong plz tell mee
[Non-text portions of this message have been removed]