If you want to read the file Character by character, you can use c = read(inn, Char).
If you want to read the line, but split it into characters afterwards, you could just index the inp in your code (inp[2]), loop over it (for c in inp), or collect it.
If you want to get a Vector{Int} (which is presumably what you’re after), use parse.(Int, split(inp)) (with default ' ' for the second argument dlm (delimiter) of split).
I would probably use sum on eachmatch directly so I don’t have to allocate a vector of strings with split or a vector of ints (eachline is also not the most performant because it allocates a string per line I think, but it depends on what you need whether more effort is worth it)
Since you read character by character, you would read a line just containing 10
as "1" and "0" so your sum would be 1 not 10.
You have to follow the hints atop, real the whole line, split it at the spaces and then parse the individual numbers, which are often strings longer than one character.
Apart from the problem of summing digits vs. summing numbers @kellertuer highlights, there’s also the issue that you are trying to convert a space to an integer.
ERROR: ArgumentError: invalid digit: ' '
If you really want to obtain the sum while reading the file character by character, you can use an approach similar to @rocco_sprmnt21 's sumchars, though you might want to change codepoint(e) - 0x30 into parse(Int, e) for clarity.
Well, my point was mainly that for educational purposes it’s best to not use a ‘magic’ hexadecimal number . (Int(e) - Int('0') would be clearer, but also that still requires a little bit of knowledge on character encoding.)