使用VC6打开考生文件夹下的工程test40_1,此工程包含一个源程序文件test4
问题:
使用VC6打开考生文件夹下的工程test40_1,此工程包含一个源程序文件test40_1.cpp,但该程序运行有问题,请改正函数中的错误,使该程序的输出结果为:
The first result is 5
The second result is 2
The third result is 2
The fourth result is 6
源程序文件test40_1.cpp清单如下:
#include <iostream.h>
int subtraction (int a, int b)
int r;
r=a-b;
/***************** found ************************/
return &r;
int main ()
int x=5, y=3, z;
z = subtraction (7,2);
cout << "The first result is "<< z << ’\n’;
cout << "The second result is "<< subtraction(7,subtraction (7,2)) << ’\n’;
/**************** found *************************/
cout << "The third result is "<< subtraction (&x,&y) << ’\n’;
/***************** found ************************/
z= 4 + *subtraction (x,y);
cout << "The fourth result is "<< z << ’\n’;
return 0;