I am new to C programming. Please see the error in the snapshot below. I am getting undefined reference to 'square'. But when I write the function square inside the main.c file it's working!!GREAT
But I wonder what could be the reason. Please help!!
Forgive if its stupid.
This is main.c
#include "square.h"
int main()
{
int x=4,y;
y=square(x);
printf("y is %d\n",y);
return 0;
}
Now square.h
#ifndef SQUARE_H_INCLUDED
#define SQUARE_H_INCLUDED
#include <stdio.h>
#include <stdlib.h>
int square(int num);
#endif
Now square.c
int square(int num)
{
int result;
result=num*num;
return result;
}
I have edited the code as well.{I am using code blocks IDE}