Solved

parse

Posted on 2012-04-11
2
251 Views
Last Modified: 2012-04-11
Hi is it possible to use strtok to parse some data using a string as the first deliminator rather than using punctuation?


for example

data here string a b c d
more data here to disregard string e f g h

so that I only get a b c d e f g h?

Thanks
0
Comment
Question by:codey-06
[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
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 37835142
You can't do that with 'strtok()', since it uses single characters as delimiters, but 'strstr()' can help you here:

const char* get_text_afer_delimiter(cconst char* in, const char* delim) {

  char* p = strstr(in,delim);

  if (!p) return NULL; // 'delim' not found

  return p + strlen(delim);
}

// ...

char* p1 = "data here string a b c d";
char* p2 = "more data here to disregard string e f g h";

const char* p3 = get_text_afer_delimiter(p1, "string "); // include the blank, so the returned pointer points directly to "a b c d"

const char* p4 = get_text_afer_delimiter(p2, "string "); // include the blank, so the returned pointer points directly to "e f g h"

Open in new window

0
 

Author Closing Comment

by:codey-06
ID: 37835234
Thank you
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Arduino EDI - Programming language 3 126
Super Scope, DHCP 5 100
Setting variables in a stored procedure 5 79
Assignment from incompatible pointer type? 2 77
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

734 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