小编Eug*_*nca的帖子

指针和字符串C++

我在教自己C++,我对指针有点困惑(特别是在下面的源代码中).但首先,我继续向你展示我所知道的内容(然后将代码与此对比,因为我觉得好像存在一些矛盾).

我知道的:

int Age = 30;
int* pointer = &Age;

cout << "The location of variable Age is: " << pointer << endl;
cout << "The value stored in this location is: " << *pointer << endl;
Run Code Online (Sandbox Code Playgroud)

指针保存内存地址.使用间接(取消引用)运算符(*),可以访问存储在指针的内存位置的内容.在本书的代码中,我无法理解......

cout << "Enter your name: ";
string name;
getline(cin, name); //gets full line up to NULL terminating character

int CharsToAllocate = name.length() + 1; //calculates length of string input
                          //adds one onto it to adjust for NULL character
char* CopyOfName = new …
Run Code Online (Sandbox Code Playgroud)

c++ pointers

14
推荐指数
3
解决办法
4万
查看次数

new int [25,2]是什么意思?

在下面的代码中使用逗号使用第二个参数是什么意思?

int *num = new int[25,2];
Run Code Online (Sandbox Code Playgroud)

c++

8
推荐指数
3
解决办法
822
查看次数

标签 统计

c++ ×2

pointers ×1