Add pointer and password app

This commit is contained in:
Archer Fox
2025-03-01 22:20:45 +03:00
parent 1b71b5e8e3
commit 850430b62e
3 changed files with 38 additions and 0 deletions

3
go-demo-4/go.mod Normal file
View File

@@ -0,0 +1,3 @@
module password
go 1.23.6

20
go-demo-4/main.go Normal file
View File

@@ -0,0 +1,20 @@
package main
import (
"fmt"
)
func main() {
a := [4]int{1, 2, 3, 4}
reverse(&a)
fmt.Println(a)
var n *int
fmt.Println(*n)
}
func reverse(arr *[4]int) {
for idx, val := range *arr {
(*arr)[len(arr)-1-idx] = val
}
}

View File

@@ -0,0 +1,15 @@
package pointers
import "fmt"
func main() {
a := 5
pointerA := &a
double(&a)
fmt.Println(*pointerA) // Дереференс (разыменование) указателя
fmt.Println(a)
}
func double(num *int) {
*num = *num * 2
}