C++ Direct Court Pointer Name Meaning?


First, look at the following code example:

#include <iostream>
using namespace std;
int main()
 char *str = "this is a test";
 cout << "str=" << str << endl;
 cout << "*str=" << *str << endl;
 cout << "&str" << &str << endl;
 return 1;

The output results are as follows:

See some examples of direct useCout * pointer nameAt first, I felt very confused. I thought I would output the pointer directly. The output was the content stored in the memory pointed by the pointer until the end of reading the “/0” sign. Later, it was found that this was a pre-set rule of the compiler, and that was the output of the compiler. In addition, if * STR is used directly, where the str pointer variable stores the first address of the variable it points to, then the content of * STR output is naturally easy to understand the first character of the pointer pointing to the content.


Above is the whole content of this article. I hope the content of this article has some reference value for your study or work. Thank you for your support to developpaer. If you want to know more about it, please check the links below.

Recommended Today

Details of multi-path and large capacity hard disk mount under CentOS

I. application environment and requirementsBlade servers connect HP storage through fiber switches, forming a 2×2 link The storage capacity of the operating system for CentOS 6.4 64 bit mount is 2.5t Based on this application environment, two problems need to be solved: In order to ensure the stability and transmission performance of the link, multi-path […]