using System; namespace UnsafeTest { unsafe struct link { public int x; public link* next; } class Program { static unsafe void Main(string[] args) { int val; link* head = stackalloc link[sizeof(link)]; link*q =head; for(int i=0;i<=10;i++) { val = i+100; link* temp = stackalloc link[sizeof(link)]; q->x = val; q->next = temp; q = temp; } link* t = head; while(t->next!=null) { Console.WriteLine(t->x ); t = t->next; } } } }
时间: 2024-11-13 08:04:35