Hot answers tagged

2

First we've been taught to use (void) when declaring a function and use () when calling, using a function... Apart from that, void foo() means "a function foo taking an unspecified number of arguments of unspecified type", i.e. don't assume anything about the arguments of foo; all parameter checking is turned off. This special meaning is intended to ...


2

typedef void (*sighandler_t)(int); defines sighandler_t as a pointer type to a function whose return type is void and takes an int as an argument. the name of a function, just like the name of an array, decays to a pointer to a function. you could use it like that void foo(int x) { // some code } // some code sighandler_t p = foo; // p points to foo ...


1

Good question. There is no requirement to capture a return value. Just because a function returns a value doesn't mean that the calling code needs to do anything with it. For many functions, like printf, it is common to disregard the return value. However, when there are bugs in a program, those return values can become useful in diagnosing and debugging. ...


1

The keyword void actually has different meanings in different contexts. When the return type of a function is void, this means that the function doesn't return any value. For example void foo(void) { // return 10; // compile-time error } Notice also that void is used between the parentheses when defining a function to indicate that this function does ...


1

main is a special function. It's the starting point of a C program — it's called somehow magically when you execute the program from the terminal by typing its name in as follows ./programName main can be declared to receive command-line arguments. Command-line arguments are special type of arguments in a sense that they're passed to your program via the ...


Only top voted, non community-wiki answers of a minimum length are eligible