정적 메모리 할당: 두 판 사이의 차이

내용 삭제됨 내용 추가됨
LambdaCorp (토론 | 기여)
잔글 정적 할당 문서를 정적 메모리 할당(으)로 옮김: 풀 네임으로 이동
Cappiscience (토론 | 기여)
8번째 줄:
 
== 정적 할당 방법 ==
* C언어C 언어: C언어에서C 언어에서 정적 할당된 메모리는 [[스택]]에 위치하게 된다.
<source lang="c">
#define STATIC_ALLOC 100
25번째 줄:
printf("END\n");
getch();
}
</source>
 
* C# 언어 할당: C#에서도 stackalloc 키워드를 통해 정적 할당을 지원한다. 단, [[값 형식]]일 경우에만 가능하다.
<source lang="csharp">
using System;
using System.Runtime.InteropServices;
public static class Test
{
public const int STATIC_ALLOC = 100;
public static void Main()
{
char* StaticAlloc = staticalloc char[STATIC_ALLOC];
string _tmp = "Hello, World!";
Marshal.Copy(_tmp.ToCharArray(), 0, StaticAlloc, _tmp.Length);
}
}
</source>