首页 > 其他 > 详细

第9章 指针

时间:2021-05-13 10:06:20      阅读:16      评论:0      收藏:0      [点我收藏+]

指针数组和数组指针

因为 [] 比 * 优先级 高

  • 指针数组 :一个数组里存放的是指针
    int * p[4];
  • 数组指针 :
    int (* p)[4];//指向一维数组的指针变量

指向指针的指针

int ** p;

以下代码p是存放 的是 str 的地址
str是指向字符串的字符指针。
*p 代表着 输出 str的值

#include<iostream>
using namespace std;
int main() {
	const char *str =  "HelloWorld" ;
	const char** p;
	p = &str;
	cout << "p =" << *p; //p = HelloWorld
	return 0;
}

指针数组作为main()函数的参数

#include <stdio.h>
int main(int argc,char * argv[]) {
	for (int i = 0; i < argc; i++) {
		printf("i= %d , argv[%d] = %s\n", i, i, argv[i]);
	}
	return 0;
}

技术分享图片

第9章 指针

原文:https://www.cnblogs.com/appearAndLeave/p/14762694.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!