There are two files ac and bc . In ac , I have implemented the main main function, the tratata variable and contains the prototype of the function int foo(int n, int * a) , I cannot pass any parameters to this function. In another bc file, I have implemented this function, and the variable tratata should be used tratata . And how to pass this variable (not as a function argument), I honestly do not understand.

  • 1) make the global tratata variable 2) show the code - maybe there is no problem at all. - PinkTux
  • 2
    In C, it is not the variables from the file to the file that are passed, but the arguments from the function to the function. - VladD
  • @openspace Show the actual code in which the problem occurs, and how is the tratata variable used in the function if it is not declared there? - Vlad from Moscow

1 answer 1

Elementary implementation example :

 int tratata = 42; // определение глобальной переменной void f(void); // прототип функции из другого файла int main() { f(); } 

 #include <stdio.h> extern int tratata; // говорит о том, что переменная определена в другом файле void f(void) { printf("%d\n", tratata); }