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). 11 1614
G Patel wrote: 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> wrote: 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).
There' nothing that would force you to call the file with the main()
function main.c - but there's also nothing that would keep you from
doing that. Personally, I prefer to give the file with main() a name
that reflects the one of the final program since I feel that this is
somehow the most logial choice (probably due to having started with
FORTRAN where the equivalent of main() was a function with the name
of the final program (IIRC) and it thus was natural to name the file
accordingly), but if you feel differently do it as you like and no-
one is going to laugh;-) With tools like grep it is simple to find
out where main() is, so there's no reason to worry.
Regards, Jens
--
\ Jens Thoms Toerring ___ Je***********@physik.fu-berlin.de
\__________________________ http://www.toerring.de
In article <11*********************@g14g2000cwa.googlegroups. com>,
G Patel <ga********@gmail.com> wrote: 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).
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
"G Patel" <ga********@gmail.com> writes: 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).
If you have a software package that generates multiple executables,
you might have multiple files containing a main() function. In such a
case, it probably makes sense for each such source file to have a name
reflecting the name of the executable. (Or you can put them in
separate directories and call each one "main.c".)
There's no universal convention, and the C language doesn't care.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
there are many which have main.c , try google for MLAPM (used in n-body
simulations)
G Patel wrote: 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" <ga********@gmail.com> wrote in message news:<11*********************@g14g2000cwa.googlegr oups.com>... 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).
I always use
$ grep -n main\( *.c
to find main if there is no main.c or [PROGRAMNAME].c
On 2 Mar 2005 17:14:49 -0800, "G Patel" <ga********@gmail.com> wrote: 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).
Normally, you would put the main() in a file which has a name
appropriate for your program. For example, if your program is going to
be called widget, put the main in widget.c.
Consider - if I always put main() in a file named main.c, after 20
years of C programming, I would now have a thousand files named
main.c! How would I remember which was which?
--
Al Balmer
Balmer Consulting re************************@att.net
Alan Balmer wrote: Normally, you would put the main() in a file which has a name appropriate for your program. For example, if your program is going
to be called widget, put the main in widget.c.
Consider - if I always put main() in a file named main.c, after 20 years of C programming, I would now have a thousand files named main.c! How would I remember which was which?
You shouldn't have to 'remember.'
.../[Program 1 name]/main.c
.../[Program 2 name]/main.c
.../[Program 3 name]/main.c
.../[Program 4 name]/main.c
Alan Balmer <al******@att.net> writes:
[...] Normally, you would put the main() in a file which has a name appropriate for your program. For example, if your program is going to be called widget, put the main in widget.c.
Consider - if I always put main() in a file named main.c, after 20 years of C programming, I would now have a thousand files named main.c! How would I remember which was which?
Presumably you wouldn't have to remember; you could tell by the name
of the directory it's in. (This assumes a programming environment
that keeps source files in directories, of course.)
I'm not saying you *should* call it main.c, only suggesting that doing
so doesn't necessarily mean you should be laughed at.
I consider either "widget.c" or "main.c" to be a reasonable name for
the source file containing the main program for "widget". The name
"main.c" could cause problems if a single project has multiple main
programs, but you can always put them in separate subdirectories.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
On Thu, 03 Mar 2005 20:18:28 GMT, Keith Thompson <ks***@mib.org>
wrote: Alan Balmer <al******@att.net> writes: [...] Normally, you would put the main() in a file which has a name appropriate for your program. For example, if your program is going to be called widget, put the main in widget.c.
Consider - if I always put main() in a file named main.c, after 20 years of C programming, I would now have a thousand files named main.c! How would I remember which was which? Presumably you wouldn't have to remember; you could tell by the name of the directory it's in. (This assumes a programming environment that keeps source files in directories, of course.)
If your programming career is sufficiently short, simple, and
concentrated in one environment, that will work. More or less. I'm not saying you *should* call it main.c, only suggesting that doing so doesn't necessarily mean you should be laughed at.
I'll make up my own mind on that <g>. I consider either "widget.c" or "main.c" to be a reasonable name for the source file containing the main program for "widget". The name "main.c" could cause problems if a single project has multiple main programs, but you can always put them in separate subdirectories.
Hmm... That would mean the project I'm on now would have 432
directories. They could, of course, be organized as subdirectories
under the current set of directories, and I'm sure we could eventually
figure out how to get the makefiles to work again ...
Maybe next year.
--
Al Balmer
Balmer Consulting re************************@att.net
Alan Balmer wrote: On 2 Mar 2005 17:14:49 -0800, "G Patel" <ga********@gmail.com> wrote:
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).
Normally, you would put the main() in a file which has a name appropriate for your program. For example, if your program is going to be called widget, put the main in widget.c.
Consider - if I always put main() in a file named main.c, after 20 years of C programming, I would now have a thousand files named main.c! How would I remember which was which?
"There is nothing like a main()!
Nothing in the world!"
--
Eric Sosman es*****@acm-dot-org.invalid This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: OutsiderJustice |
last post by:
Hi All,
I can not find any information if PHP support multi-thread (Posix
thread) or not at all, can someone give out some information? Is it
supported? If yes, where's the info? If no, is it...
|
by: ajikoe |
last post by:
Hello,
Is anyone has experiance in running python code to run multi thread
parallel in multi processor. Is it possible ?
Can python manage which cpu shoud do every thread?
Sincerely Yours,...
|
by: * ProteanThread * |
last post by:
but depends upon the clique:
...
|
by: Joe |
last post by:
I have 2 multi-list boxes, 1 displays course categories based on a
table called CATEGORIES. This table has 2 fields CATEGORY_ID,
CATEGORY_NAME
The other multi-list box displays courses based on...
|
by: mimmo |
last post by:
Hi! I should convert the accented letters of a string in the correspondent
letters not accented. But when I compile with -Wall it give me:
warning: multi-character character constant
Do the...
|
by: dkelly925 |
last post by:
Is there a way to add an If Statement to the following code so if data
in a field equals "x" it will launch one report and if it equals "y" it
would open another report. Anyone know how to modify...
|
by: Sabri.Pllana |
last post by:
We apologize if you receive multiple copies of this call for papers.
***********************************************************************
2008 International Workshop on Multi-Core Computing...
|
by: mknoll217 |
last post by:
I am recieving this error from my code:
The multi-part identifier "PAR.UniqueID" could not be bound.
The multi-part identifier "Salary.UniqueID" could not be bound.
The multi-part identifier...
|
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= |
last post by:
As far as I know, the C Standard has no mention of multi-threaded
programming; it has no mention of how to achieve multi-threaded
programming, nor does it mention whether the language or its...
|
by: =?Utf-8?B?SGVucmlrIFNjaG1pZA==?= |
last post by:
Hi,
consider the attached code.
Serializing the multi-dimensional array takes about 36s
vs. 0.36s for the single-dimensional array.
Initializing the multi-dimensional array takes about 4s...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |