Why is it giving Compiler time error?
1. #include <stdio.h>
2. void foo()
3. {
4. return 1;
5. }
6. void main()
7. {
8. int x = 0;
9. x = foo();
10. printf("%d", x);
11. }
(1) main should return int, not void.
(2) The return type of foo() is currently void, so you can't return an int like 1 from it.
What exactly is the compile time error? The error message should be giving you clues as to what is wrong.
By the way I see more than one error, so posting the error messages would be beneficial.
Thank you very much for your answers :)