douju2012
2016-08-01 04:17
浏览 447
已采纳

使用Golang将int数组转换为char数组?

I have this error :

# command-line-arguments
.\cheking.go:14: cannot use strconv.Itoa(i + 64) + strconv.Itoa(j + 48) (type st
ring) as type [8]int in assignment

code:

package main

import (
    "fmt"
    "strconv"
)

func main() {

    var board [8][8]int

    for i := 1; i <= 8; i++ { // initialize  array
        for j := 1; j <= 8; j++ {
            board[(j-1)+8*(i-1)] = (strconv.Itoa(i+64) + "" + strconv.Itoa(j+48)) // int to char

            fmt.Printf("%s 
", board[i][j])
        }
    }
}
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题