Programming/golang
golang pointer
구차니
2022. 4. 7. 12:12
변수 타입에 포인터 임을 명시하지, 변수에 포인터를 붙일 수 없도록 문법이 변경 된 듯.
func main() { i, j := 42, 2701 // var p *int var *p int p = &i // p := &i // point to i fmt.Println(*p) // read i through the pointer *p = 21 // set i through the pointer fmt.Println(i) // see the new value of i p = &j // point to j *p = *p / 37 // divide j through the pointer fmt.Println(j) // see the new value of j } |
포인터 참조는 가능하지만, 주소 연산은 지원하지 않는건가..
C언어와는 다르게, Go는 포인터 산술을 지원하지 않습니다. |