Search code examples
command-lineparametersargvargc

Argv parameters conversion


Possible Duplicate:
Converting string to integer C

I wanted to convert a number I received from the command argv[1] into an "int". I know the argv is stored as a string, but how can I get an integer value from them. Supposing argv[1] = 10.


Solution

  • You can use the atoi() function from the C standard library:

    http://en.cppreference.com/w/cpp/string/byte/atoi