Demonstrate the effects of pointer arithmethic : Pointer Unsafe : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Pointer Unsafe »

 

Demonstrate the effects of pointer arithmethic









    

/*
C#: The Complete Reference 
by Herbert Schildt 

Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/


// Demonstrate the effects of pointer arithmethic. 
 
using System; 
 
public class PtrArithDemo { 
  unsafe public static void Main() { 
    int x; 
    int i;  
    double d; 
 
    int* ip = &i; 
    double* fp = &d; 
 
    Console.WriteLine("int     double\n"); 
 
    for(x=0; x < 10; x++) { 
       Console.WriteLine((uint) (ip) + " " + 
                         (uint) (fp)); 
       ip++; 
       fp++; 
    } 
  } 
}


           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Pointer Unsafe