0

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.

2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by johndoe444
0

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.

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.