Skip to content

Commit 3320473

Browse files
committed
adds pointer eg
1 parent 37fb369 commit 3320473

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

codes/session-1/pointer.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main() {
6+
7+
/**
8+
* Created message variable and assigned string to it.
9+
*/
10+
message := "Hello World"
11+
12+
/**
13+
* Created greeting string pointer to hold the memory address of message variable
14+
*/
15+
var greeting *string = &message
16+
17+
/**
18+
* Print message
19+
*/
20+
fmt.Println(message)
21+
22+
/**
23+
* Print greeting memory address
24+
*/
25+
fmt.Println(greeting)
26+
27+
/**
28+
* Print value of greeting
29+
*/
30+
31+
fmt.Println(*greeting)
32+
}

0 commit comments

Comments
 (0)