Array en C/C++

Publié dans Snippet | Marqué avec ,
Share

Static

int anArray[] = { 1, 2 };
// OR
int anArray[2] = { 1, 2 };
// OR
int anArray[2];
anArray[0] = 1;
anArray[1] = 2;

Dynamic (C++)

int anArray = new int[2]
anArray[0] = 1;
anArray[1] = 2;

Et ne pas oublier la suppression :

delete[] anArrat;

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*