I have 3 files . In one file I declared a structure and in another file which has the main, I am trying to access that structure using extern key word --------
//a.c---
include<stdio.h>
extern struct k ;
extern int c;
int main()
{
extern int a,b;
fun1();
fun2();
c=10;
printf("%d\n",c);
struct k j;
j.id=89;
j.m=43;
printf("\n%d\t%f",j.id,j.m);
}
//1.c
#include<stdio.h>
struct k
{
int id;
float m;
}j;
int c;
void fun1()
{
int a=0,b=5;
printf("tis is fun1");
printf("\n%d%d\n",a,b);
}
//2.c--
#include<stdio.h>
struct k
{
int id;
float m;
}j;
void fun2()
{
int a=10,b=4;
printf("this is fun2()");
printf("\n%d%d\n",a,b);
}
I compiled this code by using cc a.c 1.c 2.c
but I am getting error as storage size of ‘j’ isn’t known