main.cpp

 1 #include <iostream>
 2 #include <conio.h>
 3 
 4 #define CONTENT_SIZE 1048576
 5 using namespace std;
 6 
 7 void proc();
 8 
 9 char src[CONTENT_SIZE];
10 char dst[CONTENT_SIZE];
11 int index = 0;
12 
13 int main() {
14     int n;
15     while ( 1 ) {
16         if ( _kbhit() ) {
17             n = _getch();
18             if ( n == 27 ) //Esc
19                 break;
20             if ( n == 13 ) { //Enter
21                 proc();
22                 continue;
23             }
24             cout << ( char ) n;
25             src[index++] = n;
26         }
27     }
28     return 0;
29 }
30 
31 void proc() {
32     src[index] = '\0';
33     dst[index] = '\0';
34     for ( int i = 0; i < index; i++ )
35         dst[index - i - 1] = src[i];
36     cout << endl << dst << endl << endl;
37     index = 0;
38 }

 Reverse String 1.0 随笔

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

附件1

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄