How to get the size of bytes array in Go

1 Answer

0 votes
package main 
  
import ( 
    "fmt"
	"encoding/binary"
) 
  
func main() { 
	ba := []byte("go java c c++ php python")
  
    fmt.Printf("%d\n", binary.Size(ba));
    fmt.Printf("%c\n", ba[binary.Size(ba) - 1]);
}


   
/*
run:
   
24
n
  
*/

 



answered Aug 6, 2020 by avibootz

Related questions

1 answer 163 views
1 answer 210 views
210 views asked Aug 6, 2020 by avibootz
1 answer 268 views
1 answer 203 views
...