However, an array is a fixed size and needs to be reallocated if there are more entries than the array size: struct Table_Record table Īnother data structure for the table is a list (single or double, your choice). The simplest suggestion is to use an array. This is a decision you will have to make. #TABULAR FORM OF DATA HOW TO#The next question is how to structure the rows. I've decided to use a fixed field length for the domain name. In your example, the row can be represented by: struct Table_Record There are two issues in representing tabular data: So you should use some library for serialization or write your own for reading/writing your data. So by defining a structure you do not automatically get methods for writing/reding your data. In C (and C++) there is no built-in serialization facility like one in virtually every dynamic (or "managed") language like C#, Java, Python. Do you intend to support IP v6 also? then you need 128 bit for address. For storing IP (v4) address you may use 32 bit unsigned int - char is insufficient. I'd suggest using dynamically allocated strings here. Regarding your example I do not know restrictions on domain name lenght but "20" would be definitely insufficient. If IP and domain often come together in your program then it is reasonable to use structure or class (in C++) for that. This is the part about "tabular" format that implies text with fields delimited by tabs. How to serialize data, that is to store it in external storage e.g.How to organize data in your program (in-memory) - this is the part about using structures.You probably mixing two different questions:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |