创建一个txt文件来调用f2(),而不修改代码
creating a txt file to call f2() without modiying the code
创建一个txt文件来调用f2()而不修改代码如何输入文件并且不修改此代码文件将具有f2()的地址,然后程序将打印"hello世界"
注意:我的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:%xn",str);
printf("address of a is:%xn",&a);
cout << "The string you entered is:";
cout << str << endl;
}
void f2()
{
cout << "Hello World!n";
}
main()
{
printf("The address of function f2:%08xn",f2);
f1();
}
您可以查看缓冲区溢出的示例喜欢http://blogs.msdn.com/b/roberthorvick/archive/2004/01/16/59460.aspx
相关文章:
- 使用C++库在Android项目中修改gradle中的cmake参数,用于插入指令的测试
- 独立读取-修改-写入顺序
- Visual studio代码重构似乎不起作用(例如,重命名符号-f2)
- 当系统的卷被修改时,如何修改WASAPI环回捕获卷
- 修改函数中的指针(将另一个指针作为参数传递)
- 为什么我可以通过引用修改常量返回
- 对于结构,表达式必须是可修改的ivalue
- QML:修改在不同QML文件(而非main.QML)中定义的子对象的属性
- 为什么不能修改对象中的值?另外,我如何改进此链表?
- f2、f3、f4标识符未找到
- 修改创建帐户程序
- 我应该如何修改此代码以使用给定字符串中的字母打印菱形图案
- 如何从子成员函数修改父公共成员变量
- 修改 VS Code 中的默认C++代码段
- 为什么在我的函数类型后使用引用运算符 (&) 允许我修改它返回的值?
- 如何使用递归打印修改后的星号三角形图案
- 已修改的LinkedList未在文本文件本身中更新
- C++RapidXml-使用first_node()遍历以修改XML文件中节点的值
- 为什么可以修改数组 b?
- 创建一个txt文件来调用f2(),而不修改代码