Declaration and assignment

Report a typo

Write a body of the main function that:

  • Creates a pointer of a type string;
  • Assigns the value "my string" to the variable at the address held by the pointer;
  • Prints the variable referenced by your pointer variable.
Write a program in Go
package main

import "fmt"

func main() {
var ? = new(?) // Create a pointer variable of the 'string' type
*? = "?" // Assign "my string" to the variable at the address held by the pointer

fmt.Println(*?) // print the variable referenced by your pointer variable here!
}
___

Create a free account to access the full topic