博客
关于我
C++基础之利用指针访问数组中的元素
阅读量:386 次
发布时间:2019-03-04

本文共 316 字,大约阅读时间需要 1 分钟。

关键点:拿到数组首地址。

#include 
using namespace std;int main() { int arr[] = { 1,2,3,4,5,6,7,8,9,10 }; int *p = arr;//数组名就是数组首地址 cout << "第一个元素:" << arr[0] << endl;//1 cout << "指针访问第一个元素:" << *p << endl;//1 /* 利用指针遍历数组 */ for (int i = 0; i < 10; i++) { cout << *p << endl; p++; } system("pause"); return 0;}

结果展示:

在这里插入图片描述

转载地址:http://lyxq.baihongyu.com/

你可能感兴趣的文章
Mysql5.7版本单机版my.cnf配置文件
查看>>
mysql5.7的安装和Navicat的安装
查看>>
mysql5.7示例数据库_Linux MySQL5.7多实例数据库配置
查看>>
MySQL8.0.29启动报错Different lower_case_table_names settings for server (‘0‘) and data dictionary (‘1‘)
查看>>
MySQL8修改密码报错ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
查看>>
MySQL8找不到my.ini配置文件以及报sql_mode=only_full_group_by解决方案
查看>>
mysql8的安装与卸载
查看>>
mysqlbinlog报错unknown variable ‘default-character-set=utf8mb4‘
查看>>
mysqldump 导出中文乱码
查看>>
mysqldump备份时忽略某些表
查看>>
mysqldump实现数据备份及灾难恢复
查看>>
mysqlreport分析工具详解
查看>>
MySQL一个表A中多个字段关联了表B的ID,如何关联查询?
查看>>
MYSQL一直显示正在启动
查看>>
MySQL一站到底!华为首发MySQL进阶宝典,基础+优化+源码+架构+实战五飞
查看>>
MySQL万字总结!超详细!
查看>>
Mysql下载以及安装(新手入门,超详细)
查看>>
MySQL中B+Tree索引原理
查看>>
mysql中cast() 和convert()的用法讲解
查看>>
mysql中datetime与timestamp类型有什么区别
查看>>