{ }之内的代码块在‘{’右边数格处左对齐
{ }之内的代码块在‘{’右边数格处左对齐。
1 #include <iostream> 2 #include <process.h> 3 #include <stdlib.h> 4 #include <stdio.h> 5 /* run this program using the console pauser or add your own getch, system("pause") or input loop */ 6 using namespace std; 7 int main(int argc, char** argv) { 8 FILE *fpd,*fpw; // 声明FILE结构指针变量 9 unsigned char dw; 10 int i=0; 11 12 //以二进制读方式打开Calc.exe文件 13 if((fpd=fopen("C:\WINDOWS\Calc.exe", "rb"))==NULL) 14 { 15 cout<<"\nCould not open the file."<<endl; 16 cout<<"Exiting program."<<endl; 17 exit(1); //结束程序执行 18 } 19 20 // 以二进制写方式打开test.exe文件 21 if((fpw=fopen("test.exe", "wb+"))==NULL) 22 { 23 cout<<"\nCould not open the file."<<endl; 24 cout<<"Exiting program."<<endl; 25 exit(1); //结束程序执行 26 } 27 28 // 二进制文件读写操作,每次指定读写1个字节 29 while(!feof(fpd)) { //使用feof()判断文件尾 30 fread(&dw, 1, 1, fpd); 31 fwrite(&dw, 1, 1, fpw); 32 } 33 // 关闭文件 34 fclose(fpd); 35 fclose(fpw); 36 37 //执行Calc.exe和Calc.exe文件 38 cout<<"1 Run C:\WINDOWS\Calc.exe"<<endl; 39 system("C:\WINDOWS\Calc.exe"); 40 cout<<"-------------------"<<endl; 41 cout<<"2 Run test.exe!"<<endl; 42 system("test.exe"); 43 return 0; 44 }