C语言指针从入门到放肆

知乎Live 答疑:

C语言指针从入门到放肆www.zhihu.com《C语言指针从入门到放肆》

如何不用

for while goto

等循环语句,实现循环打印不低于100万个hello world.

提示:汇编\函数调用栈\指针

参考代码:

root@gt:/home/git/myRubbish/basis/c# cat example.c 
#include <stdio.h>        
int main (int argc,char* argv[])
{
    printf("hello hacker! \n");
	*(&argc -1) = (int) main;
	return 0;
}

效果如下,当然这是个死循环.

root@gt:/home/git/myRubbish/basis/c# ./a.out 
hello hacker! 
hello hacker! 
hello hacker! 
hello hacker! 
hello hacker! 
hello hacker! 
hello hacker! 
... 
hello hacker! 
hello hacker! 
hello hacker! 
Segmentation fault

    原文作者:ailx10
    原文地址: https://zhuanlan.zhihu.com/p/35650392
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞