New to learning c and I am having difficulties with writing a function in another source file that uses struct variables from the first source file.
basically I need to create a bubblesort function in another file to be used in my driver
this is what i am trying to do
driver.c
#include<stdio.h>
#include<stdlib.h>
#include<sort.c>
typedef struct iorb {
int base_pri;
struct iorb *link;
char filler[100];
} IORB;
int main(){
sort();
}
sort.h
void sortList(IORB * head, int(*prio)(int));
sort.c
void sortList(IORB * head, int(*prio)(int)){
// do stuff
}
but i get this error: unknown type IORB in the sort function.
how can pass the IORB to the function ?
Updated code after trying the answer: driver.c
#include<stdio.h>
#include<stdlib.h>
#include "sort.h"
#include "iorb.h"
//removed the typedef in the driver
iorb.h
#ifndef IORB_H
#define IORB_H
typedef struct iorb {
int base_pri;
struct iorb *link;
char filler[100];
} IORB;
#endif
sort.h
#ifndef SORT_H_
#define SORT_H_
void sortList(IORB * head, int(*prio)(int));
#endif
sort.c
#include "sort.h"
#include<stdlib.h>
#include<stdio.h>
#include "iorb.h"
void sortList(IORB * head, int(*prio)(int)){
//do stuff
}