Next: , Previous: , Up: Conversion Functions   [Contents][Index]


26.4.2 stoca

Sometimes we want to store strings in character arrays. The standard function stoca provides the following interface:

fun stoca = (string s, uint<8>[] ca = uint<8>[](), uint<8> fill = 0) uint<8>[]: { … }

If ca has zero length (for example, if the parameter is omitted), the function returns an array with the contents of the string s, excluding the terminating NULL. Otherwise, it fills the given array ca with the contents of the string s. If the string doesn’t fit in the array, then E_out_of_bounds is raised. If the length of the string is less than the length of the array, the extra characters are set to the fill character, which defaults to \0. The array ca is also returned.