I am developing a routing protocol on a Linux OS (ubuntu 12.04) in C language. My question is that I need to save the routing table on an external file, so that if the program is closed or the computer is shut down, the program should be able to fetch the routing table from the file when it is restarted.
What would be the easiest solution for it? I would appreciate if you could explain it a little bit. If it would help you to answer, I save the table struct routing user_list[40] here below: the smaller index has a higher priority in the table.
struct routing {
int hop_distance;
char senderID[16]; // 192.168.001.122
char gateway[16];
};
struct routing user_list[40] = { [0] = {0, {0}, {0}, {0} } };
Thank you in advance.
man fread
the easiest solution
As indicated in the comments: