I have to create a request datagram (RRQ) for a Tftp client like this:
But i can't use a struct because the fields have variable length.
i tried the struct and something iterating on a char.
I have to create a request datagram (RRQ) for a Tftp client like this:
But i can't use a struct because the fields have variable length.
i tried the struct and something iterating on a char.
Copyright © 2021 Jogjafile Inc.

Create an array of bytes and append to it. You can make this easier by using pointer arithmetic to keep track of where you've written, kind of like a cursor.
We can make life easier for ourselves by tracking where in the request memory the archive and mode strings start so we can easily find them later.
Then printing is easy. Print the 2 byte opcode. Then since a C string stops at a null byte, we can simply print the archive and mode strings.