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

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

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Semrush - keyword research tool

Linux Foundation Training and Certification

Disclosure: My content contains affiliate links.

33,431 questions

43,811 answers

573 users

How to convert an array of integers to a string in Go

2 Answers

0 votes
package main

import (
	"fmt"
	"strings"
)

func convertArrayOfIntegersToString(arr []int) string {
	var sb strings.Builder

	for _, value := range arr {
		sb.WriteString(fmt.Sprintf("%d ", value))
	}

	return sb.String()
}

func main() {
	arr := []int{5, 8, 12, 800, 3907}

	s := convertArrayOfIntegersToString(arr)

	fmt.Println(s)
}



/*
run:

5 8 12 800 3907 

*/

 



Learn & Practice Python
with the most comprehensive set of 13 hands-on online Python courses
Start now


answered Aug 1 by avibootz
0 votes
package main

import (
	"fmt"
	"strconv"
)

func convertArrayOfIntegersToString(arr []int) string {
	result := ""
	for _, val := range arr {
		result = result + strconv.Itoa(val)
	}

	return result
}

func main() {
	arr := []int{5, 8, 12, 800, 3907}

	s := convertArrayOfIntegersToString(arr)

	fmt.Println(s)
}



/*
run:

58128003907

*/

 



Learn & Practice Python
with the most comprehensive set of 13 hands-on online Python courses
Start now


answered Aug 1 by avibootz

Related questions

1 answer 90 views
90 views asked Aug 9, 2020 by avibootz
1 answer 95 views
1 answer 107 views
107 views asked Aug 11, 2020 by avibootz
1 answer 100 views
1 answer 109 views
109 views asked Oct 19, 2021 by avibootz
...