Resizing a char[x] to char[y] at runtime

后端 未结 11 1108
我在风中等你
我在风中等你 2021-02-11 01:33

OK, I hope I explain this one correctly. I have a struct:

typedef struct _MyData
{
   char Data[256];
   int  Index;
} MyData;

Now, I run into

11条回答
  •  说谎
    说谎 (楼主)
    2021-02-11 02:02

    It looks like from what you're saying that you definitely have to keep MyData as a static block of data. In which case I think the only option open to you is to somehow (optionally) chain these data structures together in a way that can be re-assembled be the other process.

    You'd need and additional member in MyData, eg.

    typedef struct _MyData
    {
       int  Sequence;
       char Data[256];
       int  Index;
    } MyData;
    

    Where Sequence identifies the descending sequence in which to re-assemble the data (a sequence number of zero would indicate the final data buffer).

提交回复
热议问题