How do I parse an int from a string?

integer, ocaml, string

Solution

You could use the 'int_of_string' function described in the documentation.

Problem

I'm trying to do this: ``` let medio a b = (a + b);; let () = Printf.printf "%d + %d = %d\n" Sys.argv.(1) Sys.argv.(2) (medio Sys.argv.(1) Sys.argv.(2)) ``` Sys.argv.(1) has to be the arg[1] ~ in C Now I want to use them like parameters for my function `medio`, but they're strings. How can I parse them into int?

Original source