C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old April 12th, 2002, 09:22 AM
C3P0's Avatar
C3P0 C3P0 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Posts: 302 C3P0 User rank is Private First Class (20 - 50 Reputation Level)C3P0 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 21 h 38 m 27 sec
Reputation Power: 7
Parsing a text file, removing multiple lines of text

Hello, new here and new to C++. I know a little about PHP, which I see is similar to C++ in some ways.

The project I'm working on is a program to open a file and remove certain lines of text and then save the revised file. I know how I'd do this in PHP, but from what I see C++ is much more powerful and I'm not yet familiar with the built in functions.

The knowns in the text files are the start of each new paragraph, and the start of each section to be removed.

The twist is that the section to be removed traverses many lines of the file.


$startofparagraph = xyz123;
$startofbadtext = 987654321;

file to be parsed:

xyz123 blah blah blah blah blahlah blah blah blahlah blah blah blahlah blah blah blahlah blah blah blahlah blah blah blah. lah blah blah blahlah blah blah blahlah blah blah blah. lah blah blah blah. lah blah blah blahlah blah blah blahlah blah blah blah. 987654321 uuuu u u uu u u uuu uuuuuuuasd lakj laksdjf la alsdkjf ads flaksd lkfja sdlkjalsdk falskdj fla lkaj sldkfj als al lkajsd lfjka lskdj fla skldjfasd alkjdlakdjfalk l alksdj lfaksd fa lkj
xyz123 blah blah blah blah blahlah blah blah blahlah blah blah blahlah blah blah blahlah blah blah blahlah blah blah blah. lah blah blah blahlah b 987654321 uuua uaus dlaksjd faa la;kjd flkajsd alk alsdk falksd fjlaksd jfasd falsdkfjals dfjka sdfasldkfj alksdjf asd ;lakj dslfkjasldjf aslkddjf alkaj f

(and so on... some files are large)


In PHP I'd create a variable that would contain the existing file text.

Then I'd use PHP's built in functions to look for the start of the first 'badtext' and get that position in the string. Then I'd get the position of the start of the next paragraph. I'd then use a function to strip out all text between the two integers. This would be repeated till I reached the end of the string.

With PHP being a simpler language, will doing the same in C++ be fairly involved?

Is there a function to strip text with a starting and ending position paremeter (for example, strip(33, 55) where 33 is start and 55 is end)?

Or will I be able to approach the project in the same way I might do it in PHP (store file contents in a string and go from there)?

Thanks for any preliminary pointers.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Parsing a text file, removing multiple lines of text


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway