开发者

store object in an array using ansi c?

I make a structure just like

struct abc {
    //any function or variable
} obje[20];

now I want that the each object of 开发者_JAVA百科abc store in array. means that arr[0] contain obj[0] only; can it is possible. if it is possible then some one help me in this matter.


If you want to copy the objects from the array obje into the array arr, you can use memcpy() from <string.h>:

#include <string.h>

struct abc arr[20];

memcpy(&arr, &obje, sizeof arr);

/* Now arr[0] has a copy of obje[0], arr[1] has a copy of obje[1], ... */
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜