Allocates a block of memory on the stack.

看板C_Sharp (C#)作者 (雪...)時間21年前 (2002/11/16 21:45), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
不知道還有沒有其他程式語言支援 stackalloc 的... -- // cs_keyword_stackallow.cs // compile with: /unsafe using System; class Test { public static unsafe void Main() { int* fib = stackalloc int[100]; int* p = fib; *p++ = *p++ = 1; for (int i = 2; i < 100; i++) *p++ = p[-1] + p[-2]; for (int i = 0; i < 20; i++) Console.WriteLine(fib[i]); } } -- ※ 發信站: 批踢踢實業坊(ptt.csie.ntu.edu.tw) ◆ From: 211.23.228.106
文章代碼(AID): #zralk9h (C_Sharp)
文章代碼(AID): #zralk9h (C_Sharp)