Why is the number different and the string the same?
05:59 11 Dec 2025

So I have this code here

#include 

typedef union Converter {
    char *c;
    int i;
} Converter;

int main(int argc, char **argv) {
    Converter f;
    f.c = argv[argc - 1];
    int num = f.i;
    printf("f.c =\t\t%s\nnum =\t\t%d\n(char*)num =\t%s\n", f.c, num, (char*)num);
    return 0;
}

And after compiling (gcc main.c -o main.exe), every time I run it (.\main wasd), the printed number is different, but the 2 strings are always the same.

Example output:

f.c =           wasd    
num =           12196704
(char*)num =    wasd

Runing it again:

f.c =           wasd
num =           6822752
(char*)num =    wasd

Why is this? Shouldn't the numbers be the same when the same string is given?

I also tried it with fixed values (argv[argc - 1] -> "yay"), and this way num is always 4214884 whatever the fixed value is

c char numbers union