Passing void

10 views
Skip to first unread message

JG

unread,
Oct 19, 2011, 6:20:17 AM10/19/11
to SystemsProgramming2011_12
I came across some c functions which do not require any arguments.
However when declaring such functions, void is used. For example:

void printHelloWorld(void)
{
printf("Hello Word\n");
}

I would like to know if there is any difference with writing void and
omitting it. They both seem to do the some thing. Furthermore, are
there certain cases where you must write void?

Thanks

Kevin Napoli

unread,
Oct 19, 2011, 8:11:09 AM10/19/11
to systemsprogr...@googlegroups.com
I think that you have to specify void when you are declaring a pointer to a function which takes no parameters. Other than that the behavior of your code should be exactly the same, with or without the void.

Joseph Cordina

unread,
Oct 20, 2011, 7:21:00 AM10/20/11
to systemsprogr...@googlegroups.com
Specifying (void) or just () is exactly the same

Regards

Joseph Cordina

JG

unread,
Oct 23, 2011, 2:15:06 PM10/23/11
to SystemsProgramming2011_12
ok thanks =)
Reply all
Reply to author
Forward
0 new messages