有关main函数的前因后果
来源:互联网 发布:嵌入式软件开发平台 编辑:程序博客网 时间:2024/05/21 11:25
以下内容摘自原文:
You would have been taught how main() is main in C? But, believe me, main() is nothing more than a word. i.e. It can be anything like Start(), Begin(), EntryPoint() etc. Before we directly go for main's hack, we must learn its basics. Here we go -
What main() is generally known for?
Ø It's entry point of a C program.
Ø Program without main() isn't possible.
Ø main() executes first.
Ø It has two parameters. i.e. argc, argv
Are these points right? See these possibilities...
Ø A C program which doesn't have main().
Ø A program which contains main() but is never called.
Ø main() has three parameters i.e. argc, argv and environ or envp.
Every program contains an entry point which is the place from where the program starts its execution. Whenever we execute a program, it gets loaded into the memory (RAM). But, instead of starting the execution from main() OS passes the control to startup() function located in crt0.c OR in wincmdln.c (if console application). This function initializes the global and environment variables (OR Environment table) for the program. i.e. argc, argv, _osver, _winmajor, _winminor, _winver, environ. Startup routine passes the values of argc, argv and environ to main() and finally calls main().
/*
Author: Bindesh Kumar Singh
Date: March, 2007
*/
#include <windows.h>
#pragma comment(linker,"/ENTRY:EntryPoint") /* Entry point set to EntryPoint() */
void main() /* Never executes */
{
MessageBox(0,"inside main()","information",0);
}
void EntryPoint() /* Entry point */
{
MessageBox(0,"inside EntryPoint()","information",0);
}
main can be bypassed by using #pragma comments. Here EntryPoint() is set to be the entry point of program.
详细内容见:http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=11485&lngWId=3
下载:Download article
- 有关main函数的前因后果
- WinDbg调试的前因后果
- 拆装机的“前因后果”
- 系统调用的前因后果
- 逻辑回归的前因后果
- 有关main的返回值
- 全面了解近视眼的前因后果
- 我成为软件工程师的前因后果!
- 我成为软件工程师的前因后果!
- ajax 的前因后果 以及优缺点
- 详解Https出现的前因后果
- 有关main方法的几个小知识点
- main函数的参数
- main函数的参数
- Main 函数的参数
- main()函数的参数
- main函数的参数
- main函数的参数
- win ps3111,Win a Playstation 3,Win a Ps 3,win ps2,playstation 3,
- win psp,Win a Playstation 3,Win a Ps 3,win ps2,playstation 3,
- win xbox 360,Win a Playstation 3,Win a Ps 3,win ps2,playstation 3,
- xbox 360 ps3,Win a Playstation 3,Win a Ps 3,win ps2,playstation 3,
- OracleDataguard数据同步复制的容灾技术方案
- 有关main函数的前因后果
- VERITASBackup Exec 9.0 for Windows Servers销售手册
- 创业的灵感
- ip format convert
- EJB3.0 消息驱动:MDB(Message Driven Bean)
- VERITAS Volume Replicator容灾方案VVR
- 需求:没有技术做不了的,只是时间问题,我们是服务部门,客户说怎么样那就怎么样了.
- VERITAS NetBackup备份方案
- 游戏编程中的人工智能(3-2)