Solved

Deleting data in a string using offset

Posted on 1998-06-13
2
161 Views
Last Modified: 2010-04-01
I have a string and a offset for that string, e.g.
string : “c:\dir1\dir2\file.ext”
offset : 13
and now i want to delete everything which is left from the offset. that only file.ext stays.
how can i do that ???
0
Comment
Question by:sbartok
  • 2
2 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 0 total points
ID: 1165828
copy the information forwards within the string, like

strcpy(string,string+13);
0
 
LVL 22

Expert Comment

by:nietod
ID: 1165829
Note technically this has a problem.  The two strings specified to strcpy should not overlap.  But it shouldn't be a problem when shifting forwards.  When shifting backwards it could be a problem.  You can use memmove() or a seperate string buffer if you want to be really safe.
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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
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 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.
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.

895 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

13 Experts available now in Live!

Get 1:1 Help Now