C++, array, pointer

0.

1. syntax

int foo[5]; // an array of int, an empty array

int foo[5] = {16, 2, 77, 40, 123}; // an array of int with initilization

int* ptr[5]; // an array of pointer, each pointer points to an int

double *p; // a pointer pointing to a double

vector<int> v; // an array of int

vector<int*> vp; // array of pointer, each pointer points to an int

原文地址:https://www.cnblogs.com/sarah-zhang/p/12235421.html

时间: 2024-10-16 14:19:24

C++, array, pointer的相关文章

the internal array pointer

The foreach construct provides an easy way to iterate over arrays. foreach works only on arrays and objects, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable. There are two syntaxes:

c/c++指针总结[pointer summary]

[本文链接] http://www.cnblogs.com/hellogiser/p/pointer-summary.html 1.指针注意事项 (1). 指针类型字符串不容许修改 char *str1="abcd"; char str2[]="abcd";的区别.指针类型的字符串一般不允许修改,如:str1[0]='c':这样的语句会导致运行时错误. C++ Code 123456789101112131415   void test_string() {    

网络套接字与寻址

1 套接字描述 套接字是通信端点的抽象,创建一个套接字使用如下函数: #include <sys/socket.h> int socket(int domain, int type, int protocol); 返回值:若成功,返回套接字描述符:若出错,返回-1. 参数: domain: 指定通信的特征,包括地址格式,以AF_开头的常数表示地址族(address family): 域 描述 AF_INET IPv4因特网域 AF_INET6 IPv6因特网域 AF_UNIX UNIX域 AF

typeof()关键字

typeof是GNU c标准的关键字. typeof()的作用是自动推导出括号中表达式的数据类型. 1 #include <stdio.h> 2 3 void func1(void) 4 { 5 int a = 1; 6 typeof(int *)pa = &a;//pa的数据类型为int型的指针 7 8 printf("pa:\t%p\n", pa); 9 printf("&a:\t%p\n", &a); 10 printf(&

【图像算法】七种常见阈值分割代码(Otsu、最大熵、迭代法、自适应阀值、手动、迭代法、基本全局阈值法)

图像算法:图像阈值分割 SkySeraph Dec 21st 2010  HQU Email:[email protected]    QQ:452728574 Latest Modified Date:Dec.21st 2010 HQU 一.工具:VC+OpenCV 二.语言:C++ 三.原理(略) 四.程序 主程序(核心部分)  代码 1 /*===============================图像分割=====================================*/2

Balanced and stabilized quicksort method

The improved?Quicksort?method of the present invention utilizes two pointers initialized at opposite ends of the array or partition to be sorted and an initial partition value Pvalue located at the center of the array or partition. The value at each

GCC对C的扩展总结

在Linux内核代码中,有非常多的代码使用了GCC的很多扩展特性,本篇文章主要是对这些特性做一个小小的总结,代码全部来自于GCC手册 1.被一对花括号包起来的代码块可以作为一个表达式来使用,花括号中可以使用循环语句(while.for),开关语句(if.switch),本地变量等.代码如下: 1 2 3 4 ({ int y = foo (); int z;     if (y > 0) z = y;     else z = - y;     z; }) 最后一条语句必须为一个表达式并以分号结

[转]50 Shades of Go: Traps, Gotchas, and Common Mistakes for New Golang Devs

http://devs.cloudimmunity.com/gotchas-and-common-mistakes-in-go-golang/ 50 Shades of Go: Traps, Gotchas, and Common Mistakes for New Golang Devs Go is a simple and fun language, but, like any other language, it has a few gotchas... Many of those gotc

PatentTips - Optimizing Write Combining Performance

BACKGROUND OF THE INVENTION The use of a cache memory with a processor facilitates the reduction of memory access time. The fundamental idea of cache organization is that by keeping the most frequently accessed instructions and data in the fast cache