.


:




:

































 

 

 

 





. , ,

int a[5];

, int, a, (&a[0]):

, , , a:

*(a+1) = *(a+4)+1; // , a[1] = a[4]+1;

, , , a+1 , a+4 .

,

int a[5];

int *ptr = a;

ptr a. ptr a . , ptr a. , :

a[1] = 1;

*(ptr+1) = 1;

() () . const, :

int a, b;

...

const int *xPtr; //

int* const iPtr = &a; //

const int * const dcPtr = &b; //

( , ).

, .

- , :

int a[25], *p;

p = a;

p++; //

a++; //

, : char. char . , , C/C++ , .

() . , , ( char), (). .

"" char:

char* s1 = "The string";

s1 "The string".

char s2[] = "The string";

s1 , "The string", s2 11 ( "The string" ) . , : s2 , , s1, , .

char s2[] = {'T','h','e',' ','s','t','r','i','n','g','\0'};

, .

#include <ctype.h>

, -, char.

#include <string.h>

. , , , - ( , , , ). :

( *)

, :

short int i = 0x1010; // 1*4096+ 1*16 = 4112

short *ptr = &i;

short int j = *ptr;

short int k = *(char*)ptr;

j 0x1010 k 0x10.

( ) , , . void:

void * _;

, void, . , , , . :

int a = 125;

double d = 10.3975;

short b[4] = {0, 1, 2, 3};

void *vp;

...

vp = &a;

cout << *(int*)vp << endl; // a

vp = &d;

cout << *(double*)vp << endl; // d

vp = b;

cout << *((short*)vp+1) << endl; // b[1]

vp = (short*)vp+2; // vp

cout << *(short*)vp << endl; // b[2]

vp , . , , . vp int*, double* short*.

, , . , .

char *ch[10];

, ch 10 , char.

( char) , ,

char* s[5] = { "one", "two", "three", "four", "five" };

char* s[] = { "one", "two", "three", "four", "five" };

s . s , s , s[0], s[0], , s[4] . , *s, s[0], s, s[0][0], *s[0] ( [] , *) **s .

++ , .

int **p;

, p , , *, p, int. , .., ( ). ,

int ***v;

.





:


: 2016-07-29; !; : 2030 |


:

:

, , .
==> ...

1889 - | 1529 -


© 2015-2024 lektsii.org - -

: 0.013 .