我有main.c
struct
和查找表。
现在我想将struct head
的地址“发送”到另一个C文件并调用它。
如何从名为head
的查找表中获取地址并将其用于其他C文件?
// all is in the same main.c
//int main is in my main.c
int main()
{
init();
searcher();
return 0;
}
//Look up tables are in my main.c too
static ExTable head[] ={
{"hugo" , c ,NULL},
{"bernd" , d ,NULL},
{"anna" , a ,NULL},
{"\0"}
};
我只在这里添加exTable
,因为所有其他(a-z)只有其他名称和子标记。
static ExTable a[] = {
{"Say" , c ,NULL},
{"Show" , b ,NULL},
{"\0"}
};
//my init ...
//here i think i would set the adress from my head
void init()
{
}
// in my tester.h
// is my struct and a lot of funktiondeclarations
typedef struct Table
{
char* name;
struct Table* subtab;
void (*pfn)(char*);
} ExTable;
在我的tester.c
我有一个void findname(ExTable* table, char* input)
和
这应该找到名字。这个方法对你来说是无内容的:)但它需要一个static Extable* table
和一个char*
,
我会在tester.c
//searcher is in my tester.c
void searcher()
{
//....................
// inputs is a char[]
inputs[strlen(inputs)-1] = '\0';
// in head should be the adress from the head Look Up Table
//head is only an exable , i dont have it in my program because i dont know who i became the adress from my header LUT in my main to my tester.c in my parameter. when i wrote header , it doesn't works
findname(head, inputs);
}