none
Parsing Data RRS feed

  • Question

  • Hi Everybody,

    I need code to parsing data. I have packet like this:

    fld_Title=Title:Mrs;fld_Name=Name:Lola;


    my code:

      TCHAR seps[]   = _T(";");

                TCHAR * token;
                   
                token  = _tcstok( szFileName, seps );
               
                MessageBox(NULL, token, _T("Token 1"),MB_OK);

    (output: fld_Title=Title:MrsWink


    I use this code to parsing data until ";". How can i get data/string after " : " (--> Mrs) ?

    Please help n Thnx.
    Thursday, September 18, 2008 9:30 AM

Answers

  • you can write code like this:

     

    TCHAR sep[] = _T(";");

    TCHAR *token;

    token = _tcstok(szFileName, seps );

    MessageBox(NULL, token, _T("Token 1"),MB_OK);

    while (token != NULL)

    {

    token = _tcstok(NULL, seps );

    MessageBox(NULL, token, _T("Token Next"),MB_OK);

    }

     

    Saturday, September 20, 2008 6:52 AM

All replies


  • Simply use string classes . Or if you wann do some work you can check with strtok() also.

    Thanx
    Friday, September 19, 2008 7:34 AM
  • you can write code like this:

     

    TCHAR sep[] = _T(";");

    TCHAR *token;

    token = _tcstok(szFileName, seps );

    MessageBox(NULL, token, _T("Token 1"),MB_OK);

    while (token != NULL)

    {

    token = _tcstok(NULL, seps );

    MessageBox(NULL, token, _T("Token Next"),MB_OK);

    }

     

    Saturday, September 20, 2008 6:52 AM
  • Hi bobcy,

    I just wanna get string after " : "

    example :
    fld_Title=Title:Mr

    I wanna get value "Mr".

    Can u tell me the code.


    Thnx.
    Wednesday, September 24, 2008 4:17 AM
  • You can use CString class.Have a look in MSDN everything is there just try it.

    Thanx
    Saturday, September 27, 2008 6:31 AM