Use code tags to post your code.
instead of including myfile.h you must include myfile.c
ajay.krish123
Junior Poster in Training
90 posts since Nov 2008
Reputation Points: 6
Solved Threads: 9
// call this myfile.h
#include <stdio.h>
int sum ( int, int );
int sum ( int x, int y )
{
return x + y;
}
// Program to be run: main.c
#include <stdio.h>
#include "myfile.h"
int main ( void )
{
//clrscr();
printf ( "The sum of 3 and 5 is %i", sum ( 3, 5 ) );
getchar();
return 0;
//getch();
}
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
Putting code in headers is generally bad form....if you include that same header in more than one file in a compilation unit you get duplicate symbols.
The original layout of the files should have worked, did you include myfile.obj or myfile.o when you compiled main.c?
Murtan
Practically a Master Poster
671 posts since May 2008
Reputation Points: 344
Solved Threads: 116