Following is my code, I am trying to run it in Visual Studio.
#include <stdio.h>
#include <conio.h>
int main()
{
//int i;
//char j = 'g',k= 'c';
struct book
{
char name[10];
char author[10];
int callno;
};
struct book b1 = {"Basic", "there", 550};
display ("Basic", "Basic", 550);
printf("Press any key to coninute..");
getch();
return 0;
}
void display(char *s, char *t, int n)
{
printf("%s %s %d \n", s, t, n);
}
It gives an error of redefinition on the line where opening brace of function is typed.
You call
displaybefore declaring it, and in such cases the compiler assumes the return type isint, but your return type isvoid.Declare the function before using it:
Also note, that you declare it as receiving
char*, but pass string literals to it (const char*) either change the declaration, or change the arguments, e.g: