question about atoi

Hi,

1. If the program get some char (as an argument argv[1]), and I want to use this char, can I do:

ch = (char)atoi(argv[1]);

Is this a proper use?
No. atoi is not a standard C++ function and converts a C string to an integer.

This is all you need:
ch=argv[1][0];
I'm sorry, I should have mentioned that I use C and not C++
Does it make any difference?

Cause if it converts a C string to an Integer and I want to convert it back to char, shouldn't it be aloud?
Does it make any difference?

No.

Cause if it converts a C string to an Integer and I want to convert it back to char, shouldn't it be aloud?

No. I thought you wanted the first (and apparently only character) of the parameter?
So what is this about converting it to an integer?
calling atoi with any non-numeric string always returns 0.
Topic archived. No new replies allowed.