Click here to Skip to main content
15,898,820 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: help me debug this pls Pin
Mike Dimmick26-Jul-05 2:43
Mike Dimmick26-Jul-05 2:43 
Questionhow to................. Pin
Member 214683925-Jul-05 23:27
Member 214683925-Jul-05 23:27 
AnswerRe: how to................. Pin
David Crow26-Jul-05 2:50
David Crow26-Jul-05 2:50 
AnswerRe: how to................. Pin
Member 214683926-Jul-05 4:59
Member 214683926-Jul-05 4:59 
Generaltapi 2.2 lineMonitorTones Pin
nripun25-Jul-05 22:53
nripun25-Jul-05 22:53 
GeneralUse of string in switch case Pin
itkid25-Jul-05 22:53
itkid25-Jul-05 22:53 
GeneralRe: Use of string in switch case Pin
berndg25-Jul-05 23:56
berndg25-Jul-05 23:56 
GeneralRe: Use of string in switch case Pin
Iain Clarke, Warrior Programmer26-Jul-05 0:23
Iain Clarke, Warrior Programmer26-Jul-05 0:23 
You cannot use a string in switch cases - the cases have to be constant numberic values.

If the strings are not known at compile time, then you have to use if...else if...else
statements.

If they are known at compile time, then you can precompute hashes of the case strings,
and switch on a hash of the string you want to switch on. Um, that wasn't very clear,
was it?

void DoSomethingDependingOnString (LPCTSTR szSwitchable)
{
    switch (ComputeHash(szSwitchable))
    {
    case 0x4wfe:  // ComputeHash ("I am a string!")
        DoFirstThing ();
        break;

    case 0xfg13:  // ComputeHash ("I am another string!")
        DoSecondThing ();
        break;

    default:
        DoDefaultThing ();
        break;
    }
}


I hope that was little clearer.

Iain.
GeneralRe: Use of string in switch case Pin
berndg26-Jul-05 4:18
berndg26-Jul-05 4:18 
GeneralRe: Use of string in switch case Pin
markkuk26-Jul-05 12:09
markkuk26-Jul-05 12:09 
GeneralRe: Use of string in switch case Pin
itkid27-Jul-05 2:31
itkid27-Jul-05 2:31 
QuestionHow to monitor a file's actions? Pin
wood25-Jul-05 22:52
wood25-Jul-05 22:52 
AnswerRe: How to monitor a file's actions? Pin
David Crow26-Jul-05 2:57
David Crow26-Jul-05 2:57 
GeneralSorry,my explanation isn't clear! Pin
wood26-Jul-05 15:36
wood26-Jul-05 15:36 
GeneralRe: Sorry,my explanation isn't clear! Pin
David Crow27-Jul-05 2:42
David Crow27-Jul-05 2:42 
Generalsetting Timeout ..Please help me out Pin
Smith#25-Jul-05 22:51
Smith#25-Jul-05 22:51 
GeneralRe: setting Timeout ..Please help me out Pin
Marc Soleda25-Jul-05 23:31
Marc Soleda25-Jul-05 23:31 
GeneralRe: setting Timeout ..Please help me out Pin
Smith#26-Jul-05 1:12
Smith#26-Jul-05 1:12 
GeneralRe: setting Timeout ..Please help me out Pin
Smith#26-Jul-05 1:17
Smith#26-Jul-05 1:17 
GeneralRe: setting Timeout ..Please help me out Pin
Marc Soleda26-Jul-05 1:21
Marc Soleda26-Jul-05 1:21 
GeneralRe: setting Timeout ..Please help me out Pin
Smith#26-Jul-05 1:24
Smith#26-Jul-05 1:24 
GeneralRe: setting Timeout ..Please help me out Pin
Marc Soleda26-Jul-05 1:34
Marc Soleda26-Jul-05 1:34 
GeneralRe: setting Timeout ..Please help me out Pin
David Crow26-Jul-05 3:06
David Crow26-Jul-05 3:06 
GeneralXML parsing using C++ Pin
72arpita25-Jul-05 22:47
72arpita25-Jul-05 22:47 
GeneralRe: XML parsing using C++ Pin
Marc Soleda25-Jul-05 23:27
Marc Soleda25-Jul-05 23:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.