T
ting
I'm a newer in C++.
I hope to output a string's address. The program is as follows:
#include <iostream>
using namespace std;
int main()
{
char *str="ABCD";
char *p;
p=str;
//output "ABCD" address.why is (long)p different from (void *)p ?
cout<<"(long)p = "<<(long)p<<endl;
cout<<"(void *)p = "<<(void *)p<<endl;
return 0;
}
I don't understand why (long)p is different from (void *)p . please
tell me. thanks in advance.
I hope to output a string's address. The program is as follows:
#include <iostream>
using namespace std;
int main()
{
char *str="ABCD";
char *p;
p=str;
//output "ABCD" address.why is (long)p different from (void *)p ?
cout<<"(long)p = "<<(long)p<<endl;
cout<<"(void *)p = "<<(void *)p<<endl;
return 0;
}
I don't understand why (long)p is different from (void *)p . please
tell me. thanks in advance.