I have a sub.h file that defines a variable and a structure, then in my sub.c I have a function that modify said variable and structure to a different value.
//main.c
#include <stdio.h>
#include <stdint.h>
#include "sub.h"
int main(void){
  
  change();
  printf("Main: a=%d - b=%d\n",trial->a,b);
  trial->a = 10;
  b = 15;
  printf("Main: a=%d - b=%d\n",trial->a,*ptr);
  
}
//sub.h
#include <stdint.h>
#include <stdio.h>
static struct TEST{
  int a;
}test;
static struct TEST *trial = &test;
static int b;
static int *ptr = &b;
void change(void);
//sub.c
#include "sub.h"
void change(void){
  trial->a = 20;
  *ptr = 25;
  printf("Change function: a=%d - b=%d\n",trial->a,b);
}
//Output
Change function: a=20 - b=25
Main: a=0 - b=0
Main: a=10 - b=15
When I call the function change() in my main the modified values would not be carried over. I'd like to know what I could do differently so that the values modified in sub.c would be carried to main.c
