翠花儿,上代码~!

无意(确实是无意)间写了这么一个程序,它既没调用里面的打印”hello!”的函数,也没使用循环,却是无限循环地打印”hello!”!这个程序是不可移植的,在Win上应该不行,在Linux上可能也有差异。我是在FC5上编译运行的,效果不错。

include

include

void foo(char arg)
{
volatile int foo = 3;
volatile int bar = 9;
char str[8];
strcpy(str, arg);
printf(“ret=%pn”, (int
)(&foo - 1));
}

void hello()
{
printf(“hello!n”);
}
int main(void)
{
char t[32] = { 0 };
memset(t, ‘x90’, 31);
unsigned long ptr = (unsigned long )&t[20];
ptr = (unsigned long)&hello;
ptr = (unsigned long
)&t[24];
*ptr = (unsigned long)&main;
printf(“hello@%pn”, hello);
foo(t);
return 0;
}