In Ansi C std C89 I want to send the following structure using text protocol via TCP network socket

char text[1024];

struct Prot {
   char id[4];
   char type[2];
   int dim;
} dato;
sprintf(text, "%s %s %d",, dato.type, dato.dim);

I want to use fix dimension every time I send this structure; my doubt is about int data because I know dimension of first 2 field (4 +2) id+type but I don't know how code this data into text to have fixed dimension,


AA BBBB 1245"

these strings have different dimensions depend of int value of 3rd field.

if I fixed 10 as maximum string length I'll got 4 char for my string but how to code this data into string so that receiver can always read 10 characters and understand all data?