小编Yas*_*Yas的帖子

移动数组指针不会更改启动的ADDRESS

我的代码:

#include <iostream>

using namespace std;

int main() {
    char *test = (char*)malloc(sizeof(char)*9);
    test = "testArry";
    cout << &test << " | " << test << endl;
    test++;
    cout << &test << " | " << test << endl;
    return 1;
}
Run Code Online (Sandbox Code Playgroud)

结果:

004FF804 | testArry
004FF804 | estArry
Run Code Online (Sandbox Code Playgroud)

我不明白我是如何移动我的数组指针和地址没有改变的.

c++ arrays string pointers

4
推荐指数
1
解决办法
128
查看次数

在函数调用中声明变量

我的结构:

struct Point {
    int x;
    int y;
    Point(int nX, int nY) { x = nX; y = nY; }
    Point() {};
};
Run Code Online (Sandbox Code Playgroud)

功能:

void functionName(Point target);
Run Code Online (Sandbox Code Playgroud)

我想在函数调用中声明变量:(伪代码)

functionName(Point variable(5,0));
Run Code Online (Sandbox Code Playgroud)

我正在用 C 或 C++ 编写。

c c++

2
推荐指数
1
解决办法
6320
查看次数

标签 统计

c++ ×2

arrays ×1

c ×1

pointers ×1

string ×1