Login Register


A Question About C filter_list
Author
Message
RE: A Question About C #2
(10-15-2015, 04:26 AM)CPU Wrote: I am learning the C programming language, and have a question to ask experienced C programmers on this forum: Does putting "void" in a function declaration's parameter list have a difference between an empty parameter list?

Example:
Code:
my_function(void);

Versus

Code:
my_function();

Do these prototypes have any difference in any way at all?
There is no difference between the two.
Quote: Also, I was reading on how the "main" function's return type could be "void". Is it true that the main function's return type can be void? If so, why, and is it different from the integer return type? Thank-you.
Yes, the main function can have a return type of void. Declaring an int was used to return a status value back to the DOS batch file that called the executable.

For example, this could be the code for SomeFile.exe:
Code:
int main() { int x = 5; if x == 5 return 1; }

In your batch file you could have something like this:
Code:
SomeFile.exe IF %ERRORLEVEL% NEQ 0 ( ECHO error - SomeFile.exe returned an error code!!! )

Reply





Messages In This Thread
A Question About C - by CPU - 10-15-2015, 04:26 AM
RE: A Question About C - by pizzaguy541 - 10-16-2015, 10:40 AM
RE: A Question About C - by CPU - 10-17-2015, 12:44 AM
RE: A Question About C - by lord of the flies - 10-17-2015, 03:01 AM
RE: A Question About C - by CPU - 10-17-2015, 03:47 AM
RE: A Question About C - by 0xDEAD10CC - 10-17-2015, 05:49 AM
RE: A Question About C - by pizzaguy541 - 10-17-2015, 02:16 PM
RE: A Question About C - by CPU - 10-17-2015, 08:55 PM
RE: A Question About C - by 0xDEAD10CC - 10-18-2015, 04:54 AM
RE: A Question About C - by CPU - 10-18-2015, 05:04 AM
RE: A Question About C - by 0xDEAD10CC - 10-18-2015, 05:10 AM
RE: A Question About C - by CPU - 10-18-2015, 05:23 AM
RE: A Question About C - by 0xDEAD10CC - 10-18-2015, 05:29 AM



Users browsing this thread: 1 Guest(s)