473,699 Members | 2,518 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6910
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*********@gm ail.comwrote in message
news:11******** ************@l7 5g2000hse.googl egroups.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************ ***********@fre e.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
--
"Considerat ion 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************ **********@l75g 2000hse.googleg roups.com>,
santosh <sa*********@gm ail.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*********@gm ail.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....@gm ail.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...@xmissio n.xmission.com (Kenny McCormack)
wrote:
santosh <santosh....@gm ail.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

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

Similar topics

8
1612
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": ------------------------------------ class A {}; struct A1 : public A {} a1;
4
2679
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 A() { $this->value = 1; }
8
10409
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 is not much help here either. Googling has given me a little help. This is my current understanding -- I would appreciate any comments or corrections... "" -- this means an empty string when applied to String data type, and also to Variant...
7
2171
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. Here's what I discovered. In addition to my main web project and several middle tier projects, I also added an "empty" web project in my solution (Add - New Project - Empty Web Project). This empty web project is what is causing the above...
0
2248
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 follows: ValidationExpression = "^\d{0,3}(\.\d{0,4})?$" The purpose of this one is to validate that numeric values input follow the syntax 999.9999. This works well. But, one thing that I have never tested previously (which has now been uncovered...
10
24176
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
5612
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 do want to erase that pair, may I do that?
4
2381
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 means the id is not exist in my Booking1 table. How should i express this " if empty " concept in python? def confirmUp(request): q=request.session b=Booking1.objects.filter(id__exact=q) if b=empty
1
1797
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 an empty area, above the tab content: / Tab 1 caption \ / Tab 2 caption \ XXXX empty space XXXX
0
8613
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9172
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8908
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8880
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4374
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.