-2

I make a structure just like

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

now I want that the each object of 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.

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
QAZI
  • 15
  • 2
  • 2
    I suspect we still don't know enough about what you are trying to achieve to be truly helpful beyond a tutorial about arrays in C. Can you extend the question with some code showing what you've tried and explain what problem you have? – RBerteig Sep 08 '10 at 09:10

1 Answers1

0

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], ... */
caf
  • 233,326
  • 40
  • 323
  • 462