Solved

breaking string into Substings

Posted on 2000-03-04
2
232 Views
Last Modified: 2010-04-02
Hi I have a string in the form of

:aaaa:bbbb:ccccccc:

How can I get substrings like "aaaa", "bbbb" "ccccccc"

Note that there are three substrings, divided by a colun sign.

Thanks
0
Comment
Question by:tparvaiz
[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 1

Accepted Solution

by:
ntdragon earned 50 total points
ID: 2582676
what is the problem
//str is your string
char*sub1;
char*sub2;
char*sub3;
int i=1;//your string starts with ':'
int j;

//then:
j=i;
while(str[i]!=':')
   i++;
//allocate the memory
sub1=new char[i-j+1];
for(int index=j;index<=i;index++)
   sub1[index-j]=str[index];
sub1[index-j]='\0';

and the same for rest two


i hope i didn't do your homework

0
 

Author Comment

by:tparvaiz
ID: 2582799
excelent and thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

691 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