创建一个txt文件来调用f2()而不修改代码如何输入文件而不修改此代码文件将具有f2()的地址,然后程序将打印“hello World”
注意:我的 f2() 地址是 00 40 10 14,相反,对于缓冲区溢出,它将被读取为 14 10 40 00
#include <iostream>
#include <cstdio>
using namespace std;
int i;
unsigned int* p;
void f1() {
int a=10;
char str[4];
cout << "Please enter a string:";
while (!cin.eof()) {
cin.get(str[i]);
i++;
}
printf("address of str is:%x\n",str);
printf("address of a is:%x\n",&a);
cout << "The string you entered is:";
cout << str << endl;
}
void f2()
{
cout << "Hello World!\n";
}
main()
{
printf("The address of function f2:%08x\n",f2);
f1();
}