【C开发】无限循环 while(1) 和 for(; ;)
2013-05-31 22:05
134 查看
无限循环有两种常用的方法:
while(1) 和 for(; ; ) 。
两种方法的效果一样,相比之下,哪种更好些?
编译后代码对比:
1、while( 1 );
PS:在VC6.0中,设断点调试,菜单View -> Debug Windows -> Disassembly即可查看编译后代码。
while(1) 和 for(; ; ) 。
两种方法的效果一样,相比之下,哪种更好些?
编译后代码对比:
1、while( 1 );
00401028 mov eax,1 0040102D test eax,eax 0040102F je main+23h (00401033) 00401031 jmp main+18h (00401028)2、for( ; ; );
00401033 jmp main+23h (00401033)对比发现,for(; ;)指令少,不占用寄存器,而且没有判断、跳转,比while( 1 )要好一些。
PS:在VC6.0中,设断点调试,菜单View -> Debug Windows -> Disassembly即可查看编译后代码。
相关文章推荐
- 【C开发】无限循环 while(1) 和 for(; ;)
- Android开发之不用for,if,while计算1--100之间的和
- vc开发-fatal error C1010: unexpected end of file while looking for precompiled header directive
- 为什么JDK源码中,无限循环大多使用for(;;)而不是while(true)?
- java学习10--循环结构-for与while区别、无限循环、循环应用
- 用Axis 1.1 for Java进行Web Services开发
- iOS开发75-leaks will report false positives while the environment variable NSZombiesEnable is active的解
- Android 开发samples for SDK独自下载
- IOS开发之——objectForKey与valueForKey在NSDictionary中的差异
- 2006年培养学员8万人,每年增长%25,请问按此增长速度,到那一年培训学员人数将达到20万人用for,while,dowhile,实现
- 不使用for、while等循环实现strlen()函数
- iOS开发之Xcode9报错 Compiling IB documents for earlier than iOS7 is no longer supported.
- shell编程中while与for的区别及效率比较
- 忙里偷闲( ˇˍˇ )闲里偷学【C语言篇】——(4)for == while ?
- Flex学习教程,第一步,如何安装Flex开发环境(For Eclipse 插件)
- ios开发——日常之Xcode编译Undefined symbols for architecture xxx 错误
- Java实现Python的for...else或while...else逻辑结构
- Cocos2D-X for XNA游戏开发指南
- iOS开发~officer for mac
- 【iOS开发-27】解决方案:An error was encountered while running(Domain=FBSOpenApplicationErrorDomain, Code=4)