I want to generate this sequential data in C:
data_packet[1] = 0706050403020100 (seed_value)
next
data_packet[2] = 0f0e0d0c0b0a0908
Next will be the next 8 hexadecimal characters and so on for say 100 bytes. How can I do it? Can we do it using character array?
You don’t want to use a
chararray sincecharmay or may not be signed (implementation defined). If you are playing with hexadecimal numbers from 0x00 to 0xFF, I strongly recommend using anunsigned chararray.Looks like the values in the array are sequential, from 0 to N. This indicates using a
forloop.The array is a fixed size of 8 bytes. Hmmm, another good candidate for a
forloop.The hard part of your task is the direction of the bytes. For example are filling in the array starting at position 7 or at position 0?
So here is some psuedo code to help you along:
For more fun, change the functionality of “put ‘value'” to “put random value”.
If you want us to actually write your program, let us know. I could use the extra money. 🙂