Discussion:
enum conversion problem
(too old to reply)
Dennis Schulz
2005-01-16 00:45:30 UTC
Permalink
Hi, I have the following problem:
I want to find out the number of the month from given string.
I defined 12 constants as a enum type num:

enum num{Jan=1, Feb=2, Mar=3, Apr=4, May=5, Jun=6, Jul=7, Aug=8,
Sep=9, Okt=10, Nov=11, Dec=12};

now I want to access the number of the month

This is working:
num n = Dec;

There is an error:
num n = static_cast<num>(MyString);

How can I convert it to a num type??

Thank you
Mathias
2005-01-23 16:26:31 UTC
Permalink
Post by Dennis Schulz
I want to find out the number of the month from given string.
enum num{Jan=1, Feb=2, Mar=3, Apr=4, May=5, Jun=6, Jul=7, Aug=8,
Sep=9, Okt=10, Nov=11, Dec=12};
now I want to access the number of the month
num n = Dec;
num n = static_cast<num>(MyString);
How can I convert it to a num type??
Thank you
Try the functions atoi, atof and so on.
Example:

char* string = "34";
int num = atoi(string); // converts the string '34' to integer
--
You don't need a reason to help people!
Loading...