Click here to Skip to main content
16,018,534 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Using Timer with non-dialog class Pin
Chuck O'Toole26-Oct-11 9:47
Chuck O'Toole26-Oct-11 9:47 
GeneralRe: Using Timer with non-dialog class Pin
aangerma26-Oct-11 10:17
aangerma26-Oct-11 10:17 
QuestionI don't understand the value of a token strtok_s Pin
jkirkerx24-Oct-11 13:42
professionaljkirkerx24-Oct-11 13:42 
AnswerRe: I don't understand the value of a token strtok_s Pin
Software_Developer24-Oct-11 14:07
Software_Developer24-Oct-11 14:07 
GeneralRe: I don't understand the value of a token strtok_s Pin
Richard MacCutchan24-Oct-11 21:45
mveRichard MacCutchan24-Oct-11 21:45 
AnswerRe: I don't understand the value of a token strtok_s Pin
Malli_S24-Oct-11 18:55
Malli_S24-Oct-11 18:55 
GeneralRe: I don't understand the value of a token strtok_s Pin
jkirkerx25-Oct-11 5:54
professionaljkirkerx25-Oct-11 5:54 
AnswerRe: I don't understand the value of a token strtok_s Pin
Richard MacCutchan24-Oct-11 21:44
mveRichard MacCutchan24-Oct-11 21:44 
I think there is quite a lot you don't understand unfortunately; this is a bit of a mess.

You need to understand the difference between a char* and a char* []. You are also using a vector in your function when you are just passing a null-terminated string. Given your array of SQL information you know that it is in pairs of strings <keyword>;<value> so you just need to split the string into it's constituent parts and process each keyword as required. Something like:
C++
void CA_SQLServer_Scan::_process_SQL_BufferData(char* pszData)
{
// pszData is the string extracted from the TCP stream buffer
    char *token1, *nextToken, *token2;
    char seps[] = ";";
    // pointers to saved token values
    char *szServerName = NULL;
    char *szInstanceName = NULL;
    char *szVersion = NULL;

    token1 = strtok_s(pszData, seps, &nextToken);
    // token1 points to the first keyword, which is now a null terminated string
    do {
        token2 = strtok_s(NULL, seps, &nextToken);
        // token2 points to the keyword's value string
        // check for any required keywords and save pointers to the values
        if (strcmp(token1, "ServerName") == 0)
            szServerName = token2;
        else if (strcmp(token1, "InstanceName") == 0)
            szInstanceName = token2;
        else if (strcmp(token1, "Version") == 0)
            szVersion = token2;
        // if token2 is NULL then there is no more data
        if (token2 == NULL)
            break;
        // get the next keyword token, and repeat
        token1 = strtok_s(NULL, seps, &nextToken);
    } while (TRUE);
    // the values saved above may now be copied elsewhere, printed, displayed on screen etc.

Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman



GeneralRe: I don't understand the value of a token strtok_s Pin
jkirkerx25-Oct-11 6:11
professionaljkirkerx25-Oct-11 6:11 
GeneralRe: I don't understand the value of a token strtok_s Pin
Richard MacCutchan25-Oct-11 6:41
mveRichard MacCutchan25-Oct-11 6:41 
GeneralRe: I don't understand the value of a token strtok_s Pin
jkirkerx25-Oct-11 6:52
professionaljkirkerx25-Oct-11 6:52 
GeneralRe: I don't understand the value of a token strtok_s Pin
Richard MacCutchan25-Oct-11 7:07
mveRichard MacCutchan25-Oct-11 7:07 
QuestionSplitter with fixed size Pin
Dialecticus24-Oct-11 8:28
Dialecticus24-Oct-11 8:28 
AnswerRe: Splitter with fixed size Pin
App_24-Oct-11 9:04
App_24-Oct-11 9:04 
GeneralRe: Splitter with fixed size Pin
Dialecticus24-Oct-11 9:30
Dialecticus24-Oct-11 9:30 
AnswerRe: Splitter with fixed size Pin
TheGreatAndPowerfulOz24-Oct-11 9:51
TheGreatAndPowerfulOz24-Oct-11 9:51 
GeneralRe: Splitter with fixed size Pin
Dialecticus24-Oct-11 10:04
Dialecticus24-Oct-11 10:04 
AnswerRe: Solution: use CSplitterWnd::SetRowInfo Pin
Goto_Label_24-Oct-11 11:18
Goto_Label_24-Oct-11 11:18 
GeneralRe: Solution: use CSplitterWnd::SetRowInfo Pin
Dialecticus24-Oct-11 22:48
Dialecticus24-Oct-11 22:48 
AnswerRe: Splitter with fixed size Pin
TheGreatAndPowerfulOz25-Oct-11 5:06
TheGreatAndPowerfulOz25-Oct-11 5:06 
GeneralRe: Splitter with fixed size Pin
Dialecticus25-Oct-11 6:14
Dialecticus25-Oct-11 6:14 
Questionhow to Add the help file in SDI Application Pin
sarfaraznawaz23-Oct-11 21:01
sarfaraznawaz23-Oct-11 21:01 
AnswerRe: how to Add the help file in SDI Application Pin
Richard MacCutchan23-Oct-11 22:38
mveRichard MacCutchan23-Oct-11 22:38 
AnswerRe: How to call the html help api Pin
App_24-Oct-11 6:25
App_24-Oct-11 6:25 
QuestionSetCurrentDirectory Pin
sarfaraznawaz23-Oct-11 19:42
sarfaraznawaz23-Oct-11 19:42 

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.