char *strcat_s(char *_string, char _buffer[100]) {
_string = _buffer;
return _string;
}
<code lang="cpp">
char *strcat_s(char *_string, char _buffer[100]) {
for (int i = 0; i < 100; i++) {
if (_string[i] == '\0')
break;
_string[i] = _buffer[i];
}
return _string;
}
</code>
char *setString(char *_string = (char *)malloc(1)) {
char _buffer[100];
int i, _lenght = 0;
_string = '\0';
cout << "Введите строку:\n";
cin.getline(_buffer, 100);
_lenght += strlen(_buffer);
_string = (char *)realloc(_string, _lenght + 1);
_string = strcat_s(_string, _buffer);
//На всякий обнуляю буффер, а то малоли.
for (int i = 0; i < 100; i++)
_buffer[i] = '\0';
return _string;
}
int main() {
int * a;
int * b;
char buffer[1000]; //буффер на 1000 байт
a = new (buffer) int;
*a = 100;
cout << "A = " << *a << endl;
cout << "Address A=" << a << endl;
b = new (buffer) int;
cout << "B = " << *b << endl;
cout << "Address B=" << b << endl;
*b = 99;
cout << "A = " << *a << endl;
cout << "B = " << *b << endl << endl;
cout << "Address A=" << a << endl;
cout << "Address B=" << b << endl << endl;
char * ch = new (buffer) char;
cout << "init char ch \n";
cout << "CH = " << ch << endl;
ch = "Hello World I am buffer ";
cout << "CH = " << ch << endl;
cout << "A = " << *a << endl;
cout << "B = " << *b << endl << endl;
cout << "Address A=" << a << endl;
cout << "Address B=" << b << endl;
cout << "Address CH=" << &ch << endl << endl;
cout << "init float f \n";
float * f = new (buffer) float;
cout << "F = " << *f;
*f = 3.14;
cout << "F = " << *f << endl;
cout << "CH = " << ch << endl;
cout << "A = " << int(*a) << endl;
cout << "B = " << int(*b) << endl << endl;
cout << "Address A=" << a << endl;
cout << "Address B=" << b << endl;
cout << "Address F=" << f << endl;
cout << "Address CH=" << &ch << endl << endl;
// Адресация массивово.
cout << "*ch =" << *ch
<< "\n ch =" << ch
<< "\n &ch =" << &ch
<< "\n &ch[0] =" << &ch[0]
<< "\n *ch == ch[0]. ch == &ch[0]";
system("pause");
return 0;
Router#ping 192.168.0.35
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.0.35, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/1 ms
Router(config)#do ip bgp
ip bgp
^
% Invalid input detected at '^' marker.
Router(config)#do sh ip bgp
BGP table version is 71, local router ID is 100.0.0.17
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 104.0.0.0/24 117.0.0.2 0 0 0 108 109 104 i
* 105.0.0.0/24 117.0.0.2 0 0 0 108 109 105 i
*> 108.0.0.0/24 117.0.0.2 0 0 0 108 i
*> 109.0.0.0/24 117.0.0.2 0 0 0 108 109 i
*> 116.0.0.0/24 117.0.0.2 0 0 0 108 109 104 120 116 i
* 116.1.0.0/24 117.0.0.2 0 0 0 108 109 104 120 116 i
*> 117.0.0.0/24 0.0.0.0 0 0 32768 i
*> 120.0.0.0/24 117.0.0.2 0 0 0 108 109 104 120 i
*> 192.168.0.0/23 117.0.0.2 0 0 0 108 109 104 120 i
Router(config)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to down
%BGP-5-ADJCHANGE: neighbor 117.0.0.2 Down Interface flap
%BGP-5-ADJCHANGE: neighbor 116.1.0.1 Up
%BGP-5-ADJCHANGE: neighbor 105.0.0.1 Up
Router(config)#do sh ip bgp
BGP table version is 87, local router ID is 100.0.0.17
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 104.0.0.0/24 116.1.0.1 0 0 0 116 120 104 i
* 105.0.0.1 0 0 0 105 109 104 i
* 105.0.0.0/24 116.1.0.1 0 0 0 116 120 104 109 105 i
* 105.0.0.1 0 0 0 105 i
* 108.0.0.0/24 116.1.0.1 0 0 0 116 120 104 109 108 i
*> 105.0.0.1 0 0 0 105 109 108 i
* 109.0.0.0/24 116.1.0.1 0 0 0 116 120 104 109 i
*> 105.0.0.1 0 0 0 105 109 i
*> 116.0.0.0/24 116.1.0.1 0 0 0 116 i
* 105.0.0.1 0 0 0 105 109 104 120 116 i
* 116.1.0.0/24 116.1.0.1 0 0 0 116 i
* 105.0.0.1 0 0 0 105 109 104 120 116 i
*> 117.0.0.0/24 0.0.0.0 0 0 0 117 i
*> 120.0.0.0/24 116.1.0.1 0 0 0 116 120 i
* 105.0.0.1 0 0 0 105 109 104 120 i
*> 192.168.0.0/23 116.1.0.1 0 0 0 116 120 i
* 105.0.0.1 0 0 0 105 109 104 120 i
Router(config)#do sh run
Building configuration...
Current configuration : 1065 bytes
!
version 15.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Router
!
!
!
!
!
!
ip cef
no ipv6 cef
!
!
!
!
license udi pid CISCO2911/K9 sn FTX152410ZM
!
!
!
!
!
!
!
!
!
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface Loopback0
ip address 100.0.0.17 255.255.255.255
!
interface GigabitEthernet0/0
ip address 117.0.0.1 255.255.255.252
duplex auto
speed auto
!
interface GigabitEthernet0/1
ip address 105.0.0.2 255.255.255.252
duplex auto
speed auto
!
interface GigabitEthernet0/2
ip address 116.1.0.2 255.255.255.252
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
router bgp 117
bgp log-neighbor-changes
no synchronization
neighbor 117.0.0.2 remote-as 108
neighbor 105.0.0.1 remote-as 105
neighbor 116.1.0.1 remote-as 116
network 100.0.0.0 mask 255.255.254.0
network 117.0.0.0 mask 255.255.255.0
!
ip classless
ip route 117.0.0.0 255.255.255.0 Null0
!
ip flow-export version 9
!
!
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
login
!
!
!
end
Router(config)#
ip route 192.168.0.0 255.255.254.0 FastEthernet1/0