Solved

breaking string into Substings

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 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.

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now