【举例说明】测试C++中数组空间是否连续

/*
 * @Author: benjie
 * @Date: 2021-11-15 21:35:20
 * @LastEditTime: 2021-11-15 21:41:09
 * @LastEditors: benjie
 * @Description: 测试数组在内存空间是否连续
 * C++中二维数组在地址空间上也是连续的
 */
#include<iostream>
#include<vector>

using namespace std;

// 0x61fdd0
// 0x61fdd4
// 0x61fdd8
// 0x61fddc
// 0x61fde0
// 0x61fde4
void test_array() {
    int array[6] = {0,1,2,3,4,5};
    cout << &array[0] << endl;
    cout << &array[1] << endl;
    cout << &array[2] << endl;
    cout << &array[3] << endl;
    cout << &array[4] << endl;
    cout << &array[5] << endl;
}
// 0x61fdd0 0x61fdd4 0x61fdd8
// 0x61fddc 0x61fde0 0x61fde4
void test_two_array() {
    int array[2][3] = {
        {0,1,2},
        {3,4,5}
    };
    cout << &array[0][0] << " " << &array[0][1] << " " << &array[0][2] <<endl;
    cout << &array[1][0] << " " << &array[1][1] << " " << &array[1][2] <<endl;
}

int main() {
    test_array();
    test_two_array();
    return 0;
}

本文作者:benjieqiang

本文链接:https://www.cnblogs.com/benjieqiang/p/15558451.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   benjieqiang  阅读(241)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起
🔑
  1. 1 蒹葭(古筝版) 徐潮城
蒹葭(古筝版) - 徐潮城
00:00 / 00:00
An audio error has occurred.

作词 : 诗经

作曲 : 徐潮城

蒹葭-徐潮城

编:刘文

蒹葭苍苍白露为霜

所谓伊人在水一方

溯洄从之道阻且长

溯游水中央

蒹葭萋萋白露未晞

伊人在水湄

溯洄从之道阻且跻

溯游水中坻

蒹葭苍苍白露为霜

所谓伊人在水涘

伊人在水一方

蒹葭采采白露未已

溯洄从之道阻且右

溯游水中沚

蒹葭萋萋白露未晞

伊人在水湄

溯洄从之道阻且跻

溯游水中坻

蒹葭苍苍白露为霜

所谓伊人在水涘

伊人在水一方

蒹葭采采白露未已

溯洄从之道阻且右

溯游水中沚

蒹葭苍苍白露为霜

所谓伊人在水涘

伊人在水一方

蒹葭采采白露未已

溯洄从之道阻且右

溯游水中沚