typedef struct { unsigned char length; char* data; }STRING; 没注意楼主说的长度最大255,已改正; 在我的项目中,我用到了很多这种结构体,很实用;
typedef struct { unsigned char length; char* data; }STRING;
typedef struct { int length; char* data; }STRING;
typedef struct { char length; char* m_str; } STRING; 这样写吧,然后需要用到的时候就指定length,动态申请m_str的空间吧,但是这个最大长度应该就不止255了吧?
定义成char *就可以了,不用指定长度,只要你确定好结束符'\0'就可以了
70,024
社区成员
243,263
社区内容
加载中
试试用AI创作助手写篇文章吧