0

Code Coach

Hey Guys, I've been trying my skills now for about a week on this Code Challenge. Since this is not really explained in the course I really need some help. So if there are any ideas feel free to help me. Reset the Timer The given code declares a Timer struct, which is initialized in main(). You need to add a reset functionality to the program. The reset() function needs to take a pointer to the struct as its argument and reset the seconds value to 0. Do not change the code in main(). Add the reset() function, so that the code you are given works as expected. CODE package main import "fmt" type Timer struct { id string seconds int } func main() { var x int fmt.Scanln(&x) t := Timer{"ABC", x} reset(&t) fmt.Println(t) }

4th Oct 2021, 11:48 AM
Stefan
Stefan - avatar
3 Réponses
+ 1
Hey buddy, I honestly never used GO and I don't even know its syntax, so I might be completely wrong, but here is my guess: (it seems to work as required): https://code.sololearn.com/ctr3y9lIV6bu/?ref=app
4th Oct 2021, 12:16 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 1
Thank you it seems to work. Indeed I never tried to use a pointer direktly to the struct.
4th Oct 2021, 1:32 PM
Stefan
Stefan - avatar
+ 1
Stefan, no problem mate 👍 And happy learning!
4th Oct 2021, 1:38 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar