Solved

Parsing string...

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

MyField1=sometext\r\n
MyField2=moretext\r\n
MyField3=alittletext\r\n

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?

-CS
0
Question by:csullins
    4 Comments
     
    LVL 30

    Accepted Solution

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

    Example:

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

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

    Expert Comment

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

    0
     
    LVL 2

    Assisted Solution

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

    Expert Comment

    by:Axter
    Recommend even split
    0

    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 (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. 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