//a.h---
#include<stdio.h>
#include "1.h"//cannot know its there without including it first.
#include "2.h"
extern struct k;// don't really need to do this and is wrong.
extern int c;
//a.c
int main()
{
extern int a,b;//externs i believe should be in the h file?
fun1();
fun2();
c=10;
printf("%d\n",c);
struct k *ptr = malloc(sizeof(struct k));//Define our pointer to the struct and make use of malloc.
//now we can point to the struct, update it and even retrieve.
ptr->id = 89;
ptr->m = 43;
printf("\n%d\t%f" ptr->id,ptr->m);
}
//1.h
#include<stdio.h>
typeof struct k
{
int id;
float m;
}j;
//1.c
int c;
void fun1()
{
int a=0,b=5;
printf("tis is fun1");
printf("\n%d%d\n",a,b);
}
//2.h--
#include<stdio.h>
struct k
{
int id;
float m;
}j;
//2.c
void fun2()
{
int a=10,b=4;
printf("this is fun2()");
printf("\n%d%d\n",a,b);
}
Я отредактировал ваш код местами, поэтому он должен увидеть структуру и указать на нее.Каждый файл C должен знать, имеет заголовок h файла.Когда ах, принадлежащий вашему основному файлу, включает в себя файлы, он не только может их видеть, но и должен иметь к ним доступ.Это означает, что он также должен знать, что K является J, псевдоним K, если я правильно помню.
Я должен знать, обновить структуру и получить данные из нее через указатель.Если это все еще не работает, пожалуйста, опубликуйте свою ошибку компиляции и скопируйте и вставьте строку, по которой она плачет.