Solved

Deleting data in a string using offset

Posted on 1998-06-13
2
160 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
Comment Utility
copy the information forwards within the string, like

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

Expert Comment

by:nietod
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
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 …
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 learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

771 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

9 Experts available now in Live!

Get 1:1 Help Now