@Silver - Thank you for your kind words. If there have been helpful posts, please give them a thumbs up. You can see that Saravanan makes many helpful posts. This helps everyone be able to identify the most pertinent postings as well as give people recognition for their contribution.

Help the community by fixing grammatical or spelling errors, summarizing or clarifying the solution, and adding supporting information or resources. Always respect the original author.

As you could see, 00 00 00 05 is the length of the string "Hello" being stored at the first four bytes of the data.

string(int)[int] is the length prefixed vector having the elements type as length prefixed strings. The total number of elements will be stored at the first four bytes and then before each element, the length of the element will be stored.

Hi,
order_setup is not set to string(int)[int] . order_setup is a type of record with two fields whose data type are length prefixed string.
order_rec is a vector of type record i.e order_setup.
To answer your second question - why is field1 and feild2 datatype is string(int), I have no idea about your business. But you need to understand the difference between string(int) and string("\0").
string(int) is a length prefixed type string and
string("\0") is a delimited type string.
The length prefixed string type stores the length of the string at the begining of the field value, i.e 00 00 00 05 as seen in the previous example.
The delimited string say for ex, string("\0") stores the delimiter "\0" at the end of the field value.

Yes, the length stored at the beginning of the string is the number of characters in the string. If the length of the string changes, the prefix value also changes accordingly.

Using string(int) only requires memory space needed to store the string. Using string(100) requires 100 characters (sometimes bytes) regardless of the number of characters in the string. If only two characters are stored in the string(100) field or variable, it still requires 100 characters (sometimes bytes) of memory.

@Silver - Thank you for your kind words. If there have been helpful posts, please give them a thumbs up. You can see that Saravanan makes many helpful posts. This helps everyone be able to identify the most pertinent postings as well as give people recognition for their contribution.

Thank you very much for the continuous followup. I guess we are in busy world... Most users are just in need of solution, once they get it, they forget about the issue being answered and turn busy with something else. Only few peers I have seen in this forum take a time to give their feedback on the issue and mark the helpful answers.