1.Pointers
Each program variable is stored in the computer's memory at some location, or address.
A pointer is a variable that holds the value of such an address.
For example:
Given a type T, the type T* denotes a pointer to a variable of type T.
Two essential operators are used ti manipulate pointers.
The first returns the address of an object in memory,
and the second returns the contents of a given address.
2.Arrays
An arrays is a collection of elements of same type.
Given any type T and a constant N, a variable of type T[N] holds an array of N elements,
each of type T.Each element of the array is referenced by its index, that is, a number
from 0 to N-1.
3.Pointers and Arrays
The name of an array is equivalent to a pointer to the array's initial element and vice versa.
for example:
char c[] = {'c', 'a', 't'};
char* p = c;
// p points to c[0]
char* q = &c[0];
// q also points to c[0]
cout << c[2] << p[2] << q[2];
// outputs "ttt"
4. Strings
A string literal such as "Hello, World", is represented as a fixed-length array of characters
that ends with the null character. Character strings represented in this way are called C-stype
strings. since they are inherited from C, unfortunately, this representation alone does not
provide many string operations, such as concatenation and comparison. It also possesses all the
peculiarities of C++ arrays, as mentioned earlier.
For this reason, C++ provides a string type as part of its Standard Template Library(STL). When
we need to distinguish, we call these STL strings. In order to use STL strings it is necessary
to include the header file <string>.
分享到:
相关推荐
//定义一个指向指针的指针,并赋予指针数组首地址所指向的第一个字符串的地址也就是abc\0字符串的首地址 cout*b|"*(b+1)|"*(b+2); //------------------------------------------------------------------------- ...
用指针数组的方法将字符串排序
指针数组为字符串排序,char* str[] = { "beijing","guangdong","shanghai" };进行排序,内涵冒泡排序和快速排序,原理:更改指针指向
指针数组字符串排序.c
用指针数组的方法将字符串排序
301-用指针数组作为函数的参数显示多个字符串(51单片机C语言实例Proteus仿真和代码)301-用指针数组作为函数的参数显示多个字符串(51单片机C语言实例Proteus仿真和代码)301-用指针数组作为函数的参数显示多个字符串...
基于Keil的指针数组作为函数的参数显示多个字符串.rar(源码)基于Keil的指针数组作为函数的参数显示多个字符串.rar(源码)基于Keil的指针数组作为函数的参数显示多个字符串.rar(源码)基于Keil的指针数组作为函数...
指针与字符串指针数组多级指针及练习PPT学习教案.PPTx
C语言教学课件:14-3_指针数组(用于处理二维数组或多个字符串).ppt
第9章 指针和数组—指针数组及其在字符串处理中的应用C语言程序设计第9章 指针和数组问题:存储一个字符串集合的最佳方式是什么?二维的字符数组问题的提出105C语
C语言34:用指针数组作为函数的参数显示多个字符串
数组例程详解 指针例程详解 字符串例程详解 PPT详细描述数组、指针和字符串在C程序中的应用
详细介绍了易如何用指针来操作字符串和字符串指针,包括指针数组传参。
C语言用指针将字符串数组位置颠倒,实现ABCDEFGHIJKLMNOPQRSTUVWXYZ转换成ZYXWVUTSRQPONNOPQRSTUVWXYZ
实验与指导-数组指针字符串 指针与数组区别
单片机C语言实例34:用指针数组作为函数的参数显示多个字符串.txt
C++课程-3_数组指针与字符串 C++课程-3_数组指针与字符串
指针数组定义:如果一个 数组,其元素均为指针型数据,该数组为指针数组,也就是说,指针数组中的每一个元素相当于一...使用指针数组中各元素分别指向若干个字符串,使字符串的处理更加灵活。 程序1.1 代码如下:#inclu
单片机C语言实例--301-用指针数组作为函数的参数显示多个字符串.zip
c++实验课上做的代码,关于数组、指针与字符窜 整个实验报告都有