Created
March 25, 2017 22:12
-
-
Save bl4ckb0ne/439da9b97fc98b0badf421d6a26f6e5d to your computer and use it in GitHub Desktop.
Fill C array with smaller C arrays http://coliru.stacked-crooked.com/a/de90378788620cf2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstring> | |
int main() | |
{ | |
float* biga = new float[6]; | |
float* a = new float[3]; | |
a[0] = 1.0f; | |
a[1] = 1.0f; | |
a[2] = 1.0f; | |
std::memcpy(&biga[0], &a[0], sizeof(float) * 3); | |
float* b = new float[3]; | |
b[0] = 2.0f; | |
b[1] = 2.0f; | |
b[2] = 2.0f; | |
std::memcpy(&biga[3], &b[0], sizeof(float) * 3); | |
for(size_t i = 0; i < 6; ++i) | |
{ | |
std::cout << biga[i] << ' '; | |
} | |
std::cout << '\n'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment