when i run my code i am getting this error how to solve it.
ERROR:-
add.c:3:1: warning: return type defaults to 'int' [-Wimplicit-int]
main()
^
CODE:-
add.h file
#ifndef _GREETER_H
#define _GREETER_H
int greet(const char *name, int year, char *out);
#endif
add.c file
#include "add.h"
#include <stdio.h>
int greet(const char *name, int year, char *out) {
int n;
n = sprintf(out, "Greetings, %s from %d! We come in peace :)", name, year);
return n;
}
when i compile(gcc -c add.c) it i get the above error.
Hi. The error code is a warning that the function main() has no return type defined and defaults to int which isn’t really good. Better to be explicit about the return types. However the function isn’t at line 3 in the add.c listing you present here so either something wierd is happening or you don’t list the same version as the one you tried to compile.