Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

malloc c

int main(int argc, char *argv[])
{
    int* memoireAllouee = NULL;

    memoireAllouee = malloc(sizeof(int));
    if (memoireAllouee == NULL) // Si l'allocation a échoué
    {
        exit(0); // On arrête immédiatement le programme
    }

    // On peut continuer le programme normalement sinon

    return 0;
}
Source by openclassrooms.com #
 
PREVIOUS NEXT
Tagged: #malloc
ADD COMMENT
Topic
Name
8+2 =