Parsing string...

Posted on 2004-10-29
Last Modified: 2013-11-20
This is using VC++ 6... I have a char* that has the following format:


I want to parse it and grab the data after the = sign.

For example:

char* s1 will contain the text "sometext", etc.

What is the best way to take care of this?

Question by:csullins
    LVL 30

    Accepted Solution

    Use CString class to store the data, and then you can easily parse the data.


    CString Line1 = "MyField1=sometext\r\n";

    CString Value = Line1.Mid(Line1.Find('=') + 1);
    LVL 30

    Expert Comment

    If you want to use C style string, then you can use strtok function to parse the data.

    LVL 2

    Assisted Solution

    Using CString you may also want to TrimRight() to remove the trailing newline :-)
    LVL 30

    Expert Comment

    Recommend even split

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

     Java Android Coding Bundle

    Whether you're an Apple user or Android addict, learning to code for the Android platform is an extremely valuable, in-demand skill. It all starts with Java, the language behind the apps and games that make Android the top platform it is today.

    This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
    Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    877 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now