.


:




:

































 

 

 

 


3_2_1.




#include <iostream>

using std::cin;

using std::cout;

using std::endl;

Int main()

{

char string1[20],// 20 :

//19 1

string2 [] = " ";// 16 :

//15 1

cin>> string1; //cin ,

//

cout<<" string1:"<<endl;

for (int i=0; string1[i]!= '\0'; ++i) //

cout<<string1[i]<<' '; // ,

// string 1

cout<<endl;

cout<<" string2:" <<string2<<endl;// string2

system("pause");

return 0;

}

 

( < cstring >), :

strlen

strcpy, strncpy

strcmp, strncmp

strstr

strtok (,

)

 

3_2_2. strlen ()

 

# include < cstring >

#include <iostream>

using std::cout;

Int main()

{

// strlen

char * str = "12321";

int k=1;

for(int i=0; i < static_cast<int>(strlen(str)/2); ++i) {

if (str[i]!= str[strlen(str) - i - 1]){ // -1 ,

// !

k=0; break;

}

}

k? cout<<"true\n": cout<<"false\n"; // "true"

system("pause");

return 0;

}

 

cc

 

, . . .

, .

. , - , , .

, , , .

:

*_; // ,

// _ _

:

int x = 5; // x

int *ptr_ x;// ptr _ x

void *ptr_ v;// ptr _ v

xptr = &x;// ptr_ x x

// &

//

int y = *ptr_ x;// * ,

// , ,

// . y 5.

// y int y = x

ptr _ x = static _ cast < int *>(ptr _ v); //

// :

// ptr _ x ptr _ v

. , . const , , , .

:

int x; // x

const int c x=1; // cx

int * ptr_x; // ptr _ x

const int* ptr _ c x; // ptr _ cx

int* const ptr _x=& x;// cptr _ x -

const int* const ptr_cx=& x;

// cptr _ cx -

( ptr _ c x) "" , . , .

( cptr _x) "" , . .

, , .

:

int * ptr; // ptr

*ptr++ = 10; // :

// 1. , ptr, 10;

// 2. ptr ,

// .

// : *ptr = 10; ptr++;

(*ptr)++; // ptr 1

, .

, .

:

&_; // ,

// _ _

:

Int i;

int & rfc = i; // rfc i





:


: 2018-10-14; !; : 306 |


:

:

.
==> ...

1999 - | 1874 -


© 2015-2024 lektsii.org - -

: 0.012 .