PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, October 17, 2022

[FIXED] How do I parse an int from a string?

 October 17, 2022     integer, ocaml, string     No comments   

Issue

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?


Solution

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



Answered By - Hugh Rawlinson
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing