정적 메모리 할당: 두 판 사이의 차이
내용 삭제됨 내용 추가됨
LambdaCorp (토론 | 기여) |
Cappiscience (토론 | 기여) |
||
8번째 줄:
== 정적 할당 방법 ==
*
<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>
|