重複の可能性:
Malloc または通常の配列定義?
C と動的変数には動的メモリがあることがわかります。
#include <stdio.h>
int a = 17;
int main(void)
{
int b = 18; //automatic stack memory
int * c;
c = malloc( sizeof( int ) ); //dynamic heap memory
*c = 19;
printf("a = %d at address %x\n", a, &a);
printf("b = %d at address %x\n", b, &b);
printf("c = %d at address %x\n", *c, c);
free(c);
system("PAUSE");
return 0;
}
使用するメモリの種類を知るにはどうすればよいですか? いつどちらか一方をネッドするのですか?