GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 24-Aug-2008, 11:07
aaf102 aaf102 is offline
New Member
 
Join Date: Aug 2008
Posts: 2
aaf102 is on a distinguished road

Remove char from a file


Hi, i am doing some work with files in C/C++ and i wonder if there is some way, how to remove a word (array of chars) from a file. Thanks for any suggestions.
  #2  
Old 24-Aug-2008, 15:01
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 803
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: Remove char from a file


Well to start off, do you know how to open and read characters and strings froma a file in c++?
If not, search this forum for examples using '#include <fstream>'
There happens to be a thread with a good short example VERY close by right now.
  #3  
Old 24-Aug-2008, 16:55
aaf102 aaf102 is offline
New Member
 
Join Date: Aug 2008
Posts: 2
aaf102 is on a distinguished road

Re: Remove char from a file


Yes, I know how to read from a file. I just need a better solution for removing words from files than load the whole file into the memory, delete the words I want, and store it back to file.
  #4  
Old 24-Aug-2008, 19:43
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 803
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: Remove char from a file


Well then, get familiar with these iostrean class functions: cplusplus.com/reference/iostream/iostream/ ,,,,or ..../fstream/
All kinds of fun stuff in there. Find a way to 'get' whole words from a stream (hint hint).
If I didn't want to store and manipulate the file data in memory I think I might just:
CPP / C++ / C Code:
while( there are words in the file) { 
  read a word from the file 
  if( not on your list of bad words...)
    write the word to a new file 
}
Why don't you write something and post back when you run into problems.
Last edited by Howard_L : 24-Aug-2008 at 20:32.
 
 

Recent GIDBlogOnce again, no time for hobbies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile errors on FLU floogy FLTK Forum 14 05-Aug-2008 13:10
Airport Log program using 3D linked List : problem reading from file batrsau C Programming Language 11 29-Feb-2008 08:44
Double linked List & File System NatsoumiMaya C Programming Language 1 10-Feb-2008 09:23
Pointer initialization causing program abend? emanresu C Programming Language 0 12-Dec-2006 11:36
After execution - Error cannot locate /Skin File? WSCH C++ Forum 1 05-Mar-2005 21:03

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 22:32.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.