Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Covert CString to int in VC++

ramesh_vcramesh_vc Member Posts: 4
Hi,

I have the CString Variable
CString name = "PROGRAM";
I want to convert that CString variable into integer and i need
to compare that in the switch statement.
How to convert the CString variable in the integer and to use with the switch statement.

switch(name)
{
case PROGRAM:

case APP:

default:

}

Thanks in advance

Thanks
ramesh


Comments

  • LundinLundin Member Posts: 3,711
    [code]const CString all_possible_strings [n] =
    {
    "PROGRAM",
    "SOME OTHER STRING",
    ...
    };[/code]

    Search the string array for a matching string and use the array index in the switch. That's more or less the same thing as this:

    [code]if(strcmp(my_string, "PROGRAM") == 0)
    {
    }
    else if(strcmp(my_string, "SOME_OTHER_STRING") == 0)
    {
    }
    else if(...


    [/code]
  • ramesh_vcramesh_vc Member Posts: 4
    : [code]: const CString all_possible_strings [n] =
    : {
    : "PROGRAM",
    : "SOME OTHER STRING",
    : ...
    : };[/code]:
    :
    : Search the string array for a matching string and use the array
    : index in the switch. That's more or less the same thing as this:
    :
    : [code]: if(strcmp(my_string, "PROGRAM") == 0)
    : {
    : }
    : else if(strcmp(my_string, "SOME_OTHER_STRING") == 0)
    : {
    : }
    : else if(...
    :
    :
    : [/code]:
    :

    Hi,

    Thanks alot i will try this
Sign In or Register to comment.