main.cpp
1 #include <iostream> 2 #include <conio.h> 3 #include <stdlib.h> 4 #include <unistd.h> 5 #include <fstream> 6 7 #define CONTENT_SIZE 1048576 8 9 using namespace std; 10 11 void proc(); 12 13 char src[CONTENT_SIZE]; 14 char dst[CONTENT_SIZE]; 15 int index = 0; 16 17 int main() { 18 string app_home = _pgmptr;//_pgmptr 指向应用自身的完整路径 19 app_home += "/.."; 20 chdir ( app_home.c_str() ); 21 int n; 22 while ( 1 ) { 23 if ( _kbhit() ) { 24 n = _getch(); 25 if ( n == 27 ) //Esc 26 break; 27 if ( n == 13 ) { //Enter 28 proc(); 29 continue; 30 } 31 cout << ( char ) n; 32 src[index++] = n; 33 } 34 } 35 return 0; 36 } 37 38 void proc() { 39 src[index] = '