0

I apologize if im not using the right terms because this is sort of new to me.

I have a file called utils.h that has a structure with two ints:

typedef struct {   
    int pid;
    int maxClientes;
    int maxMedicos;
} Balcao;

and i have another file called balcao.c with the following code:

Balcao b;
b.pid = getpid();

I go to the terminal and insert

"Export maxClientes=20"

"Export maxMedicos=50"

"./balcao.0" (after having it compiled through gcc -o)

but when i try to print the variables it just prints out 0.

How do i capture the values from export and save them in file ?

  • 3
    [man getenv](https://man7.org/linux/man-pages/man3/getenv.3.html) – Eugene Sh. Nov 18 '21 at 18:15
  • @EugeneSh. so i have to do int *getenv(const int *maxClientes); in the structure, is that it ? – Mauro Abrantes Nov 18 '21 at 18:20
  • 1
    @MauroAbrantes, no, you don't have to *declare* `getenv`. You have to *call* it and assign the results to something. Oh, and `getenv` returns a string, in your case you probably also want to convert the result to an `int`. – HAL9000 Nov 18 '21 at 18:29
  • @JosephSible-ReinstateMonica yes, it does ! But with eugene and hals comments, i figured it out ! – Mauro Abrantes Nov 20 '21 at 09:43

0 Answers0