I have been teaching myself C and C++ and am somewhat familiar with pointers. My main question is Does const char* actually store a memory address? This question arose when working with strings. How can you assign a string to what is supposed to hold a memory address?
#include <iostream> int main(void) { const char* x = "Hello"; std::cout << x << std::endl; // Returns Hello std::cout << &x << std::endl; // Returns the actual address } To my knowledge the above code should print a memory address, so what actually is a char*?
https://stackoverflow.com/questions/65527035/char-dont-hold-the-memory-address January 01, 2021 at 11:02AM
没有评论:
发表评论