Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Parsing string...

Posted on 2004-10-29
7
Medium Priority
?
180 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
Comment
Question by:csullins
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
7 Comments
 
LVL 30

Accepted Solution

by:
Axter earned 300 total points
ID: 12450315
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
ID: 12450323
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
Ruskialt earned 300 total points
ID: 12453735
Using CString you may also want to TrimRight() to remove the trailing newline :-)
0
 
LVL 30

Expert Comment

by:Axter
ID: 12813870
Recommend even split
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Screencast - Getting to Know the Pipeline

610 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