?
Solved

breaking string into Substings

Posted on 2000-03-04
2
Medium Priority
?
236 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
2 Comments
 
LVL 1

Accepted Solution

by:
ntdragon earned 200 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

755 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