トップページ⇒tech
7コメント2KB

Cの

■ このスレッドは過去ログ倉庫に格納されています
0001名無しさんi4004NGNG
malloc&calloc
の使用方法の指南お願いします。
0002デフォルトの名無しさんNGNG
単発の質問系スレッドは嫌われている事はご存知ですか?
まずこの板の雰囲気を理解してから適切なスレッドに質問して
頂く様、お願いします。
0003全てはリリンの流れのままに(藁NGNG
無法地帯はいやなのか。鬱だ詩脳。
0004>>1NGNG
つうか死になさい
0005デフォルトの名無しさんNGNG
つーか、全員僕と一緒に詩嚢。
0006デフォルトの名無しさんNGNG
みんなイジワルね。

--------------------------------------------
void *malloc( size_t size );
--------------------------------------------
使用例:
#include <stdlib.h> /* For _MAX_PATH definition */
#include <stdio.h>
#include <malloc.h>

void main( void )
{
char *string;

/* Allocate space for a path name */
string = 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" );
}
}

--------------------------------------------
void *calloc( size_t num@` size_t size );
--------------------------------------------
使用例:
#include <stdio.h>
#include <malloc.h>

void main( void )
{
long *buffer;

buffer = (long *)calloc( 40@` sizeof( long ) );
if( buffer != NULL )
printf( "Allocated 40 long integers\n" );
else
printf( "Can't allocate memory\n" );
free( buffer );
}
0007デフォルトの名無しさんNGNG
size_t
おれこれしってる〜
さっき本で勉強したばかりだもんね!
*は関節塩山死でsh〜
■ このスレッドは過去ログ倉庫に格納されています