0

I am fairly new to C++ and am trying to understand pointers. Why does the following code output asdf instead of the memory address of a? From my understanding, a pointer is a variable that stores a memory address of type, in this case, char. So wouldnt printing p simply print the memory address of the first character?

int main()
{
    char *p="asdf";
    cout<<p;
    return 0;
}
J Lem
  • 47
  • 9

0 Answers0