473,386 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

meaning of "empty pair" of parenthesis ?

this is from Steve Summit C notes:

The empty pair of parentheses indicates that our main function accepts
no arguments, that is, there isn't any information which needs to be
passed in when the function is called. [1]

i think, an "empty pair" of parenthesis means a function can take
unlimited number of arguments

[1] http://www.eskimo.com/~scs/cclass/notes/sx1a.html

Mar 14 '07 #1
10 6868
arnuld wrote:
this is from Steve Summit C notes:

The empty pair of parentheses indicates that our main function accepts
no arguments, that is, there isn't any information which needs to be
passed in when the function is called. [1]

i think, an "empty pair" of parenthesis means a function can take
unlimited number of arguments
Not in a C definition it doesn't. Nor in a declaration.

--
Chris "electric hedgehog" Dollin
The shortcuts are all full of people using them.

Mar 14 '07 #2
arnuld said:
this is from Steve Summit C notes:

The empty pair of parentheses indicates that our main function accepts
no arguments, that is, there isn't any information which needs to be
passed in when the function is called. [1]
Steve is correct. (More precisely, our main function accepts no
parameters. But it's a fine point.)
i think, an "empty pair" of parenthesis means a function can take
unlimited number of arguments
But Steve just explained what it means! What grounds do you have for
believing that Steve is wrong?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Mar 14 '07 #3

"arnuld" <ge*********@gmail.comwrote in message
news:11********************@l75g2000hse.googlegrou ps.com...
this is from Steve Summit C notes:

The empty pair of parentheses indicates that our main function
accepts no arguments, that is, there isn't any information which
needs to be passed in when the function is called. [1]

i think, an "empty pair" of parenthesis means a function can take
unlimited number of arguments
Consider:

void foo();
void bar(void);
void baz() {}

foo is a function that takes an unspecified number of arguments. bar and
baz are both functions that take zero arguments. See the differences?

(This doesn't make perfect sense because it's a historical artifact of C.
C++ is much saner; if you learned the C++ rules thinking they were C rules,
you'll be very confused. C++ is not C.)

S

--
Stephen Sprunk "Those people who think they know everything
CCIE #3723 are a great annoyance to those of us who do."
K5SSS --Isaac Asimov
--
Posted via a free Usenet account from http://www.teranews.com

Mar 14 '07 #4
In article <45***********************@free.teranews.com>,
Stephen Sprunk <st*****@sprunk.orgwrote:
>i think, an "empty pair" of parenthesis means a function can take
unlimited number of arguments
>Consider:

void foo();
void bar(void);
void baz() {}

foo is a function that takes an unspecified number of arguments. bar and
baz are both functions that take zero arguments. See the differences?
To be explicit: in pre-ANSI C, function declarations specified only
the return type, not the arguments, and definitions specified the
arguments with a syntax like this:

int main(argc, argv)
int argc;
char **argv;
{
...

So if you see

int foo();

this is an old-style declaration of foo which does not specify the
arguments. It doesn't mean it has an unlimited number, it just doesn't
say anything about it.

The modern way to write it is:

int foo(void);

if it doesn't take any arguments, or (for example):

int foo(int a, double b);

if it takes an int and a double argument.

In modern C, the function definition looks the same as the declaration:

int foo(void)
{
...

but in old-style it would look like:

int foo()
{
...

so the interpretation of the empty parameter list was quite different in
declarations and definitions: in declarations it meant nothing, but in
definitions it meant that there were no arguments. The modern syntax is
more consistent, if not elegant.

Furthermore, it was (and still is in C90) legal to omit the return type
if it's int. So the original example:

main()
{
...

specifies main() as taking no arguments and returning an int.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Mar 14 '07 #5
Richard Tobin wrote:

<snip>
Furthermore, it was (and still is in C90) legal to omit the return type
if it's int. So the original example:

main()
{
...

specifies main() as taking no arguments and returning an int.
Info for "arnuld":

The C99 Standard has removed implicit int.

If a function doesn't return any value, it must be declared as
returning void.

Mar 14 '07 #6
In article <11**********************@l75g2000hse.googlegroups .com>,
santosh <sa*********@gmail.comwrote:
>Richard Tobin wrote:

<snip>
>Furthermore, it was (and still is in C90) legal to omit the return type
if it's int. So the original example:

main()
{
...

specifies main() as taking no arguments and returning an int.

Info for "arnuld":

The C99 Standard has removed implicit int.
So? There's no foul here. Poster claimed that both before and after
the C90 spec was published, implicit int was legal. And he is right.
>If a function doesn't return any value, it must be declared as
returning void.
Only if you are using C99 or some other environment that requires it
(such as "gcc -Wall")

Mar 14 '07 #7
On 14 Mar 2007 05:24:21 -0700, in comp.lang.c , "arnuld"
<ge*********@gmail.comwrote:
>this is from Steve Summit C notes:

The empty pair of parentheses indicates that our main function accepts
no arguments, that is, there isn't any information which needs to be
passed in when the function is called. [1]
in a definition, this is correct.
>i think, an "empty pair" of parenthesis means a function can take
unlimited number of arguments
No.
In a declaration it would mean the function took an unspecified number
of arguments, and the function definition would have to say precisely
how many.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Mar 14 '07 #8
"santosh" <santosh....@gmail.comwrote:
Richard Tobin wrote:
Furthermore, it was (and still is in C90) legal to omit the
return type if it's int. So the original example:

main()
{
...

specifies main() as taking no arguments and returning an int.

Info for "arnuld":

The C99 Standard has removed implicit int.
True.
If a function doesn't return any value, it must be declared as
returning void.
Not strictly true. C99 continues to support non-void functions
that don't return a value, so long as the calling function doesn't
attempt to use a return value from the function.

But note that main should not be declared as a void function
in portable code.

--
Peter

Mar 14 '07 #9
On Mar 15, 9:47 am, gaze...@xmission.xmission.com (Kenny McCormack)
wrote:
santosh <santosh....@gmail.comwrote:
Info for "arnuld":
The C99 Standard has removed implicit int.

So? There's no foul here. Poster claimed that both before and after
the C90 spec was published, implicit int was legal. And he is right.
There's nothing wrong with providing additional information
beyond a literal answer of the OP's question (as you are so
often wont to point out).

Mar 15 '07 #10
In article <11*********************@o5g2000hsb.googlegroups.c om>,
Old Wolf <ol*****@inspire.net.nzwrote:
>On Mar 15, 9:47 am, gaze...@xmission.xmission.com (Kenny McCormack)
wrote:
>santosh <santosh....@gmail.comwrote:
>Info for "arnuld":
The C99 Standard has removed implicit int.

So? There's no foul here. Poster claimed that both before and after
the C90 spec was published, implicit int was legal. And he is right.

There's nothing wrong with providing additional information
beyond a literal answer of the OP's question (as you are so
often wont to point out).
When in Rome, do like a Roman!

Mar 15 '07 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Valery | last post by:
hi All, how to make a member function, which is virtual not for a single object, but for the *pair* of objects?.. Here goes the skeleton of the code, which should ideally print "ABCD":...
4
by: Marcin Dobrucki | last post by:
I've been having some problems with a parse error that I can't figure out (PHP 4.3.11 on Solaris9). Sample code: <?php // getting strange parse errors on this class A { var $value; function...
8
by: Lyn | last post by:
I am trying to get my head around the concept of default, special or empty values that appear in Access VBA, depending on data type. The Access Help is not much (help), and the manual that I have...
7
by: Brad | last post by:
When debugging my current web project, in VS2003, I found I had lost the ability to drill down on watch objects in the Watch Window; I could only view the single value specific watch objects. ...
0
by: Shan Plourde | last post by:
Hi everyone, I have been using various regular expressions with the ASP.NET RegularExpressionValidator for quite some time. In general it works very well. One of the common regex's that I use...
10
by: mcbobin | last post by:
Hi, Here's hoping someone can help... I'm using a stored procedure to return a single row of data ie a DataRow e.g. public static DataRow GetManualDailySplits(string prmLocationID, string
1
by: newbie | last post by:
say I have a set containing pairs. set< pair<AbstractClass*, double container; container.insert(pair <objectPtrA, 0.0); .... .... at here, I don't know what is the value in that pair, but I...
4
by: kang jia | last post by:
hi currently i am getting an array from database,the code is in the following, if id do not exist variable b will render an empty array. at this time, i would like to check if this array is empty...
1
by: \(O\)enone | last post by:
I've added a TabControl to my WinForms app, and added a couple of tabs to the control. The result is that the top strip of the TabControl contains the two tabs, and then to the right of them is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
Oralloy
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.