Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
2
Task/Copy-a-string/Go/copy-a-string-1.go
Normal file
2
Task/Copy-a-string/Go/copy-a-string-1.go
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
src := "Hello"
|
||||
dst := src
|
||||
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