Family Day update
This commit is contained in:
parent
aac6731f2c
commit
9ad63ea473
2442 changed files with 39761 additions and 8255 deletions
22
Task/Copy-a-string/Go/copy-a-string-2.go
Normal file
22
Task/Copy-a-string/Go/copy-a-string-2.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
// creature string
|
||||
var creature string = "shark"
|
||||
// point to creature
|
||||
var pointer *string = &creature
|
||||
// creature string
|
||||
fmt.Println("creature =", creature) // creature = shark
|
||||
// creature location in memory
|
||||
fmt.Println("pointer =", pointer) // pointer = 0xc000010210
|
||||
// creature through the pointer
|
||||
fmt.Println("*pointer =", *pointer) // *pointer = shark
|
||||
// set creature through the pointer
|
||||
*pointer = "jellyfish"
|
||||
// creature through the pointer
|
||||
fmt.Println("*pointer =", *pointer) // *pointer = jellyfish
|
||||
// creature string
|
||||
fmt.Println("creature =", creature) // creature = jellyfish
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue