I have a data file in binary where the first four bytes are some integer that I want to read. I simply do:
int * num_rounters_p = malloc(sizeof(int));
fread(num_rounters_p, 4, 1, p_file);
printf("%d\n", *num_routers_p); // 10
This works fine (and please tell me if it doesn't!), however I do know the size of this particular value, and so it isn't really necessary to store it dynamically.
Is it possible to do something like
int x = some_read_function(4, 1, p_file);
printf("%d\n", x); // 10
Basically storing the value on stack instead of the heap? The code example above is of course not grounded in C, but I hope I got my point across :))