Solved

breaking string into Substings

Posted on 2000-03-04
2
229 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 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

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 tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

770 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