I have say a loop. At the beginning of the loop I want to fill a very large array which is an array of structures. Is there way like memcpy to fill the array without going through for loop. I figure using memcpy instead of for loop would be a faster way of doing this. But the thing is that I am not copying from any array I just want to something like this

arraycopy(dest_arr, value, size_arr).

Also there is a small thing. If the structure consists of a mixture of data types such as string, float, int etc. then it might a problem to initialize all members of the structure with same value. I would appreciate someone's idea here.

Thanks.

Recommended Answers

All 2 Replies

memset() will fill an array with a value. If you need special logic to copy a value, then some kind of manual loop is pretty much the only way.

memset() will fill an array with a value. If you need special logic to copy a value, then some kind of manual loop is pretty much the only way.

Thanks buddy boy. This is the thing I was looking for.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.