Advertisement
ivandrofly

Pointer Test

Apr 28th, 2015
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.55 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     unsafe static void Main()
  6.     {
  7.         fixed (char* value = "sam")
  8.         {
  9.             char* ptr = value;
  10.             ++ptr;
  11.             Console.WriteLine(*ptr); // Print a [s][a][m] 0+1 -> a
  12.             char ptr1 = *value; // Print t (Increment character e.g: s => t)
  13.             ++ptr1;
  14.             Console.WriteLine(ptr1);
  15.             Console.ReadLine();
  16.             while (*ptr != '\0')
  17.             {
  18.                 Console.WriteLine(*ptr);
  19.                 ++ptr;
  20.             }
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement