ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Somebody will correct me if I am wrong, but I believe it's related to old c code. If there was not a void as a parameter and just empty parentheses it could take a number of arguments. (think I remember reading this, but it may be a lie lol).
Heres some info on the subject from The C programming language K&R
...A note of history: the biggest change between ANSI C and earlier versions is how functions
are declared and defined. In the original definition of C, the power function would have been
written like this:
/* power: raise base to n-th power; n >= 0 */
/* (old-style version) */
int base, n;
int i, p;
p = 1;
for (i = 1; i <= n; ++i)
p = p * base;
The parameters are named between the parentheses, and their types are declared before
opening the left brace; undeclared parameters are taken as int. (The body of the function is
the same as before.)
The declaration of power at the beginning of the program would have looked like this:
No parameter list was permitted, so the compiler could not readily check that power was being
called correctly. Indeed, since by default power would have been assumed to return an int, the
entire declaration might well have been omitted.
to declare a function then it can be passed any number of arguments. You can also do the same with function pointers
Don't do this as a regular thing it will bite you in the end.:
int foo1(int a, int b)
int foo2(int a)
int main(int argc, char *argv)
typedef int (*F)();
Last edited by jim mcnamara; 08-01-2006 at 09:09 AM.
The type void in function parameter is to make clear the function has no arguments and the type void in function type is to make clear the function returns nothing.
In old C, a function could be declared as
In this declaration the implicit return type is integer and we could say nothing about its parameters (it could be declared with parameters later in the code). To avoid such indetermination the void type was introduced.