看板 C_Sharp 關於我們 聯絡資訊
不知道還有沒有其他程式語言支援 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