|
Cet article a fait l'objet d'une traduction automatique. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. Informations supplémentaires.
|
Traduction
Source
|
malloc
void *malloc( size_t size );
|
|
|||
|
|
_set_new_mode(1)
|
|
|
|---|---|
|
malloc |
|
bibliothèques
// crt_malloc.c
// This program allocates memory with
// malloc, then frees the memory with free.
#include <stdlib.h> // For _MAX_PATH definition
#include <stdio.h>
#include <malloc.h>
int main( void )
{
char *string;
// Allocate space for a path name
string = malloc( _MAX_PATH );
// In a C++ file, explicitly cast malloc's return. For example,
// string = (char *)malloc( _MAX_PATH );
if( string == NULL )
printf( "Insufficient memory available\n" );
else
{
printf( "Memory space allocated for path name\n" );
free( string );
printf( "Memory freed\n" );
}
}
espace mémoire alloué pour le nom de chemin d'accès
mémoire libérée Non applicable. Pour appeler la fonction C standard, utilisez PInvoke. Pour plus d'informations, consultez l' exemples d'appel de code non managé.