语法错误:意外的celsfah,期望(

语法错误:意外的celsfah,期望(

问题描述:

Hello I have a problem i searched but i didn't find the solution. Can you help me please ?

if choix != 1 && choix != 2 {
  fmt.Println("you don't put a correct number!")
  continueProg=true
} else if choix == 1 {
  celsfah()
  fmt.Println("Celsius")
} else {
  //FahCels()
  fmt.Println("Fahrenheit")
}

I tried several solutions but none worked

The Function Celsfah

func celsfah(fahrenheit) {
celsius := 0
fahrenheit := 0
fmt.Println("Entrer une température en Celsius à convertir en Fahrenheit : ")
fmt.Scanln(&celsius)
fahrenheit = celsius*1.8+32
fmt.Println(&fahrenheit)
}

I've simplified your code a bit and fixed some issues to turn it into a running program. The main issues were:

  • parameter into celsfah() unnecessary
  • the final Println() statement was printing the pointer to fahrenheit instead of the value

`

package main

import (
  "fmt"
)

func main() {
  choix := 1

  if choix != 1 && choix != 2 { 
    fmt.Println("you didn't put in the correct number!")
  } else if choix == 1 { 
    celsfah()
    fmt.Println("Celsius")
  } else {
    //fahcels()
    fmt.Println("Fahrenheit")
  }
}

func celsfah() {
  celsius := 0.0 
  fahrenheit := 0.0 
  fmt.Println("Enter a temperature in Celsius to convert to Fahrenheit: ")
  fmt.Scanln(&celsius)
  fahrenheit = celsius*1.8 + 32
  fmt.Println(fahrenheit)
}

`