I have got some data in a buffer and want to put those data in an array.
typedef struct chunk
{
char data[300]; /* the bufferr. */
} CHUNK;
char *buffer, CHUNK c [100];
Assuming I have got data into the buffer, how can I put 300 char per chunk? I’m new to C so please explain me with simple example.
Thanks,
Kevin
In
C, you can copy memory from one area to another usingmemcpy(). The prototype formemcpy()is:and the description is that it copies
nbytes fromsrctodst, and returnsdst.So, to copy 300 bytes from
btoawhere bothaandbpoint to something useful,bhas at least 300 bytes of data, andapoints to at least 300 bytes of space you can write to, you would do:Now your task should be something along the lines of: