How to declare and access pointer variable?

package main
import "fmt"
func main() {
   var actualVar string = "Australia"   /* variable declaration */
   var pointerVar *string      /* pointer variable declaration */
/* store address of actual variable in pointer variable*/	
   pointerVar = &actualVar  
   fmt.Printf("\nAddress of variable: %v", &actualVar  )
   fmt.Printf("\nAddress stored in pointer variable: %v", pointerVar )
   fmt.Printf("\nValue of Actual Variable: %s",actualVar )
   fmt.Printf("\nValue of Pointer variable: %s",*pointerVar )
}
C:\golang\codes>go run example.go

Address of variable: 0x114f40e0
Address stored in pointer variable: 0x114f40e0
Value of Actual Variable: Australia
Value of Pointer variable: Australia
C:\golang\codes>

Thanks for reading. Please leave your valuable feedback and comments.

* Required Fields

No questions yet. Be the first to ask the question!