samedi 26 août 2017

Easy C array assignment

Sorry for the question, I have been doing Python and JS too much and am coming back to C++ now to assign an array.

How can it be done easier than this:

float* d1 = (float*)calloc(4,sizeof(float));
d1[0] = 1;
d1[1] = 2;
d1[2] = 3;
d1[3] = 4;

I am used to d1 = [1,2,3,4] and can not wrap my head around it...

Aucun commentaire:

Enregistrer un commentaire