0
Is it the same if we write int say_hello(); instead of void say_hello(); ? If not what's the difference ?
#include <stdio.h> void say_hello(); int main() { int i; for (i = 0; i < 5; i++) { say_hello(); } return 0; } void say_hello() { static int num_calls = 1; printf("Hello number %d\n", num_calls); num_calls++; }
1 Answer
+ 2
So void means that when you call this method nothing is returned but I guess your confused as to why somthing is being printed?? That's because the code inside the say_hello method is executed and prints directly to console and that's all, the actual method is not returning anything back to were it was called.