Solved

breaking string into Substings

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Task manager indicates my c++ program memory consumption is growing? 12 100
How to split this in C++ 4 94
C++ question 3 62
sorting efficency of sorting algorithm 30 104
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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 concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

863 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

28 Experts available now in Live!

Get 1:1 Help Now