i am trying to run a very simple C program using XCode which is typed below
1) #include <stdio.h>
2) int main ()
3) {
4) printf("Hello, World!\n");
5) func();
6) return 0;
7) }
8) void func()
9) {
10) printf("xxxx");
11) }
In line number 5 i am getting warning “Implicit declaration of func is invalid in c99” and in line number 8 i am getting an error “conflicting types for func”
please advise
Thanks,
You need to declare
func();before using it (in main), otherwise it is declared as a function that returnsint, and when the compiler gets to line 8, it sees a different declaration of the same function that returnsvoid.