有谁见过main这种用法
void main(argc,argv) int argc; char **argv{...}; 有谁见过main这种用法,到到底是代码写错了还是就有这种用法,因为完整的代码无法通过编译,所以也不知道这种用法行得通不。
void main(argc, argv)
int argc;
char **argv;
{
Window win;
unsigned int width, height; /* Window size */
int x, y; /* Window position */
unsigned int border_width = 4; /* Four pixels */
unsigned int display_width, display_height;
unsigned int icon_width, icon_height;
char *window_name = "Basic Window Program";
char *icon_name = "basicwin";
Pixmap icon_pixmap;
XSizeHints *size_hints;
XIconSize *size_list;
XWMHints *wm_hints;
XClassHint *class_hints;
XTextProperty windowName, iconName;
int count;
XEvent report;
GC gc;
XFontStruct *font_info;
char *display_name = NULL;
int window_size = 0; /* BIG_ENOUGH or TOO_SMALL to
* display contents */
progname = argv[0];
if (!(size_hints = XAllocSizeHints())) {
fprintf(stderr, "%s: failure allocating memory, progname);
exit(0);
}
int argc;
char **argv;
{
Window win;
unsigned int width, height; /* Window size */
int x, y; /* Window position */
unsigned int border_width = 4; /* Four pixels */
unsigned int display_width, display_height;
unsigned int icon_width, icon_height;
char *window_name = "Basic Window Program";
char *icon_name = "basicwin";
Pixmap icon_pixmap;
XSizeHints *size_hints;
XIconSize *size_list;
XWMHints *wm_hints;
XClassHint *class_hints;
XTextProperty windowName, iconName;
int count;
XEvent report;
GC gc;
XFontStruct *font_info;
char *display_name = NULL;
int window_size = 0; /* BIG_ENOUGH or TOO_SMALL to
* display contents */
progname = argv[0];
if (!(size_hints = XAllocSizeHints())) {
fprintf(stderr, "%s: failure allocating memory, progname);
exit(0);
}
----------------解决方案--------------------------------------------------------
函数本来有这样的定义方式.
int Fun(a)
int a;
{
a=3;
return a;
}
主函数比较特殊些,两个参数具体的含义请搜索两个参数的作用,以前有人讨论过.
----------------解决方案--------------------------------------------------------
int main(int argc, char * argv[]) /* 接受命令行参数 */
{
return 0;
}
/*
main() 函数 不应该 使用 void (虽然有些编译器上可以通过编译)
*/
/* main() 返回值是返回给操作系统的,还可以用于主函数递归 */
[此贴子已经被作者于2007-11-6 2:27:17编辑过]
----------------解决方案--------------------------------------------------------
那是ANSI C以前的函数定义方式
----------------解决方案--------------------------------------------------------
头都看大了
----------------解决方案--------------------------------------------------------
接受命令行参数 ,要在 DOS 环境中输入这些参数
----------------解决方案--------------------------------------------------------
记得以前函数定义的时候要这么写的,现在已经不常见了
你把除了这部分外的东西全删了,不就知道能不能通过编译了。
----------------解决方案--------------------------------------------------------
main函数还可以递归
----------------解决方案--------------------------------------------------------
当然可以,主函数也是函数嘛.
----------------解决方案--------------------------------------------------------
char *window_name = "Basic Window Program";
char *icon_name = "basicwin";
这样写有没有觉得不是很好....
----------------解决方案--------------------------------------------------------