I recently wanted to test my C project on visual studio (I used visual studio code) but for some reason my other file (file.c) do not recognize function from my main file (main.c). I need to manually add #include in both files. I can compile the code normally using cmd (gcc main.c). If you have any idea what cause this I would be happy to hear.
main.c:
#include <stdio.h>
#include <stdlib.h>
int randNumber = 10;
#include "file.c"
int main ()
{
int a = 10;
int b = 2;
printf ("%i", multiplication (a, b));
return 0;
}
file.c:
int multiplication (int a, int b)
{
return a * b * randNumber;
}
This runs normally in vs code but not in visual studio. (I can also compile the code with cmd outside of visual studio with the command (gcc main.c)) The thing that doesn't work is the randNumber, it gets an error saying (identifier "randNumber" is undefined).