Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,851 questions

51,772 answers

573 users

How to use struct instantiation using pointer address operator in Go

1 Answer

0 votes
package main

import "fmt"

type ST struct {
	n int
	s string
}

func main() {
	var st1 = &ST{345, "go"} 
	fmt.Println(st1)

	var st2 = &ST{}
	st2.n = 4356
	st2.s = "php"
	fmt.Println(st2) 

	var st3 = &ST{}
	(*st3).n = 75
	(*st3).s = "java"
	fmt.Println(st3) 
}



/*
run:

&{345 go}
&{4356 php}
&{75 java}

*/

 



answered Aug 24, 2020 by avibootz

Related questions

1 answer 154 views
154 views asked Mar 7, 2020 by avibootz
3 answers 243 views
1 answer 163 views
1 answer 150 views
150 views asked Aug 24, 2020 by avibootz
1 answer 200 views
2 answers 204 views
204 views asked Aug 9, 2020 by avibootz
6 answers 499 views
499 views asked Feb 25, 2020 by avibootz
...