Z
zackp
Hello,
I am learning C++ lately. This morning, out of curiosity I
constructed a simple code below, but to my surprise, when char* is
used, the program fails to print almost anything.
The only thing I got is the following:
% [0]: np =
As soon as I use a pointer to another type, everything behaves as
anticipated. This is a really trivial code, but I am completely
puzzled. Any hints are appreciated.
Compiler: gcc version 3.4.2
Environment: a Dell 1450 laptop running SUN Solaris 10 intel
Thanks,
--Zack
---------------------------------------- The test code
------------------------------------------
#include <iostream>
#include <string>
using std::cout;
using std::endl;
using std::string;
int main(void)
{
// if string* is changed to char*, then the program no longer
prints
//string* np = 0;
//string** pnp = &np;
// should figure out the reason w
char* np = 0;
char** pnp = &np;
cout << "[0]: np = " << np << endl;
cout << "[1]: pnp = " << pnp << endl;
cout << "Why the above statements not printing?" << endl;
return 0;
}
I am learning C++ lately. This morning, out of curiosity I
constructed a simple code below, but to my surprise, when char* is
used, the program fails to print almost anything.
The only thing I got is the following:
% [0]: np =
As soon as I use a pointer to another type, everything behaves as
anticipated. This is a really trivial code, but I am completely
puzzled. Any hints are appreciated.
Compiler: gcc version 3.4.2
Environment: a Dell 1450 laptop running SUN Solaris 10 intel
Thanks,
--Zack
---------------------------------------- The test code
------------------------------------------
#include <iostream>
#include <string>
using std::cout;
using std::endl;
using std::string;
int main(void)
{
// if string* is changed to char*, then the program no longer
prints
//string* np = 0;
//string** pnp = &np;
// should figure out the reason w
char* np = 0;
char** pnp = &np;
cout << "[0]: np = " << np << endl;
cout << "[1]: pnp = " << pnp << endl;
cout << "Why the above statements not printing?" << endl;
return 0;
}