![]() |
|
|
|
|
|||||||
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to return void function pointer | umen | High Level Programming | 1 | 03-22-2008 12:01 PM |
| Sorting the Void File in CSH | ilak1008 | Shell Programming and Scripting | 3 | 11-06-2005 08:02 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
What is the difference between f(...), f(void) and f()
What is the difference between f(...) , f(void),f()
I know that f(void) doesn't take any parameters, but what about f() and f(...) Does the last call of function even exists? |
| Forum Sponsor | ||
|
|
|
|||
|
Quote:
f() and f(void) are synonymous since f() is the K&R C equivalent of the ANSI C f(void). f(...) means that the function takes a variable length argument list |
|
|||
|
C99 is different from K&R foo() essentially means it takes undefined arguments.
cc -Ae means compile according to strict ANSI C99 standards.. Code:
csadev:/home/jmcnama> cc -Ae foo.c
csadev:/home/jmcnama> a.out
you found foo
you found foo
you found foo
you found foo
csadev:/home/jmcnama> lint foo.c
==============
name declared but never used or defined
__bufendtab stdio.h(744)
errno errno.h(39)
___sysconf signal.h(207)
__nl_char_size stdlib.h(79)
sigwait signal.h(232)
pthread_sigmask signal.h(234)
pthread_kill signal.h(235)
getdate_err time.h(741)
__iob stdio.h(174)
function used with a variable number of arguments
foo foo.c(4) :: foo.c(12)
foo foo.c(4) :: foo.c(13)
foo foo.c(4) :: foo.c(14)
function returns value which is sometimes ignored
foo
Here is the code: Code:
/* C99-(semi)compliant but perverse coding */
#include <stdlib.h>
int foo()
{
return printf("you found foo\n");
}
int main()
{
foo();
foo(2);
foo("hi there");
return foo("this code stinks");
}
|
|||
| Google UNIX.COM |
| Thread Tools | |
| Display Modes | |
|
|