多文件程序 - main.c推荐? [英] multi-file programs - main.c recommended?

查看:56
本文介绍了多文件程序 - main.c推荐?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以解释为什么我看到的许多多文件程序没有

main.c文件,而是将main()隐藏在具有不同名称的文件中?

这只是一个偏好,还是有一个潜规则(或优势)。


我一直用main,main来调用文件。 c,我想知道是否

对此有任何警告(这可能会阻止我被b / b嘲笑或者什么)。

Can anways explain why many multi-file programs I''ve seen don''t have a
main.c file, instead main() is hidden in a file with a different name?
Is this just a preference, or is there an unspoken rule (or advantage).

I''ve been calling the file with main, main.c, and I was wondering if
there are any caveats against this (that might prevent me from being
laughed at or something).

推荐答案

G Patel写道:
G Patel wrote:
可以解释为什么我看到的许多多文件程序都没有
a

^^^

任何人

main.c文件,而main()隐藏在一个不同的$ b $文件中b名字?这只是一个偏好,还是有一个潜规则(或
优势)。
我一直用main,main.c调用这个文件,我想知道是否
那里对此有任何警告(这可能会阻止我被嘲笑或嘲笑)。
Can anways explain why many multi-file programs I''ve seen don''t have a
^^^
anyone
main.c file, instead main() is hidden in a file with a different name? Is this just a preference, or is there an unspoken rule (or advantage).
I''ve been calling the file with main, main.c, and I was wondering if
there are any caveats against this (that might prevent me from being
laughed at or something).






G Patel< ga ********@gmail.com>写道:
G Patel <ga********@gmail.com> wrote:
可以解释为什么我看到的许多多文件程序没有
main.c文件,而是将main()隐藏在一个带有文件的文件中不同的名字?
这只是一个偏好,还是有一个潜规则(或优势)。
我一直用main,main.c调用这个文件,我想知道是否有任何警告(这可能会阻止我被嘲笑或者什么) 。
Can anways explain why many multi-file programs I''ve seen don''t have a
main.c file, instead main() is hidden in a file with a different name?
Is this just a preference, or is there an unspoken rule (or advantage). I''ve been calling the file with main, main.c, and I was wondering if
there are any caveats against this (that might prevent me from being
laughed at or something).




没有什么会强迫你用main()

函数main.c来调用文件 - 但是那里'也没有什么可以阻止你这样做。就个人而言,我更喜欢给main()一个名为

的文件反映最终程序中的一个,因为我觉得这是

某种程度上最具逻辑性的选择(可能是由于开始使用

FORTRAN,其中main()的等效函数是最终程序(IIRC)名称为

的函数,因此名称很自然相应的文件

),但是如果你有不同的感觉就行了,没有 -

一个人会笑;-)使用像grep这样的工具很简单找到

在main()的位置,所以没有理由担心。


问候,Jens

- -

\ Jens Thoms Toerring ___ Je ***** ******@physik.fu-berlin.de

\ __________________________ http://www.toerring.de


文章< 11 ************ ********* @ g14g2000c wa.googlegroups。 com>,

G Patel< ga ******** @ gmail.com>写道:
In article <11*********************@g14g2000cwa.googlegroups. com>,
G Patel <ga********@gmail.com> wrote:
可以解释为什么我看到的许多多文件程序没有
main.c文件,而是将main()隐藏在一个带有文件的文件中不同的名字?
这只是一个偏好,还是有一个不言而喻的规则(或优势)。

我一直用main,main.c调用该文件,我是想知道是否有任何警告反对这个(这可能会阻止我被嘲笑或什么)。
Can anways explain why many multi-file programs I''ve seen don''t have a
main.c file, instead main() is hidden in a file with a different name?
Is this just a preference, or is there an unspoken rule (or advantage).

I''ve been calling the file with main, main.c, and I was wondering if
there are any caveats against this (that might prevent me from being
laughed at or something).




没有规则/反对;你可以把那个文件称为main.c

如果你愿意的话。


如果我正在写一个程序来玩纸牌游戏,

机会是包含main()的文件将是

,名为solitaire.c。


奇怪的是,如果我正在写一个程序到下棋,

机会是包含main()的文件将是

,称为main.c.这背后没有特别的逻辑。

这是一时兴起的风格。


-

Rouben Rostamian



There is no rule for/against this; you may call that file main.c
if you like.

If I were writing a program to play the game of solitaire,
chances are that the file that contained main() would be
called solitaire.c.

Strangely enough, if I were writing a program to play chess,
chances are that the file that contained main() would be
called main.c. There is no particular logic behind this.
It''s a matter of whim/style.

--
Rouben Rostamian


这篇关于多文件程序 - main.c推荐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆