Jo Geraerts wrote in a message to All:
JG> In a program I want to use a ini file. I've got a predefined
JG> function that reads the value and stores it in a string (char
JG> str[2])
Be aware that str[2] can only store 1 character + NUL terminator.
JG> But the value is a number is an I want to convert it to a integer.
JG> How can I do that. I tried this:
JG> int x=(int)str;
Something similar to that _may_ be possible if you use a string class that
overloads the assignment operator.
However, you can always use this solution:
#include
int x = atoi(str);
(atoi stands for ASCII-to-integer)
greetings,
Tom
tomtorfs@village.uunet.be
--- timEd/2 1.10+
---------------
* Origin: 80X86 BBS 32-15-24.62.32 V.34/V.FC (24h/24h) (2:292/516)
|