我想将一个文件夹的文件的变量访问到另一个文件夹中的文件..我怎么能那样做

I want to access a variable of a file of one folder to the file of another folder....how can i do that?

本文关键字:文件夹 文件 另一个 怎么能 访问 变量 一个      更新时间:2023-10-16

Eg。我有一个文件1.c在文件夹a和文件2.c在文件夹B

我想将file1.c的变量"I"访问到file2.c中我该怎么做??

您可以通过在file2.c 中对变量进行外部声明来访问file2.c变量中的变量

例如,如果变量i在file1.c 中定义如下

int i = 0;

您可以通过如下声明来访问file2.c中的变量:

extern int i;

只有当它是file1.c 中定义的全局变量时,才能执行此操作