Dennis Schulz wrote:
> 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
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!


|