EmbLogic's Blog

error

#include<stdio.h>
int main()
{
int i;
i = 10;
print(i);
return 0;
}

void print(int a)
{
printf(“%d\n”,a);
}
output:warning: conflicting types for ‘print’ [enabled by default]
note: previous implicit declaration of ‘print’ was here

2 Responses to error

  1. msiddarth says:

    You have to declare the function before you use it. If the function name appears before its declaration, C compiler will follow certain rules and makes the declaration itself. If it is wrong, you will get that error.

    You have two options: (1) define it before you use it, or (2) use forward declaration without implementation

  2. manoj says:

    remove void from definition of the function, and warning will not occur.

    this warning is due to type mismatch, function that you were calling returns int and function that you have defined returns void..

    That is a problem. If you dont use void, by default function will return integer, so there will not be any warning.

    cheers..!!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>