CFanatic

Go Back   CFanatic > Programming > C++ Programming

Join CFanatic Forum Now

read file n spot blank char n re write file witout extra blank topic posted under C++ Programming which is a part of Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 12-08-2007, 12:12 PM
Junior Member
 
Join Date: Dec 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
dev1910 is on a distinguished road
| More
Question read file n spot blank char n re write file witout extra blank

Hi frenz,
I am having problem with reading fileand rewrite the file topic. As part of my project , i need to write a program that reads text from one file and writes an edited version of the same text to another file. The edited version is identical to the unedited version except that every string of two or more consecutive blanks is replaced by a single blank. Thus, the text is edited to remove any extra blank characters.

Plz someone helpin me with syntax as i dunno how to read blank char frm file n omit extra blank char...
Reply With Quote
  #2  
Old 12-17-2007, 12:43 AM
Junior Member
 
Join Date: Aug 2007
Location: East Coast USA
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
HowardL is on a distinguished road
| More
Re: read file n spot blank char n re write file witout extra blank

Well first you need to be able to:
- Open two files,, one for reading and another for writing.
http://www.cplusplus.com/reference/i...ream/open.html
http://www.cplusplus.com/reference/i...ream/open.html

- Read one character at a time from the infile.
http://www.cplusplus.com/reference/i...tream/get.html

- Process that character to determine if it is a second, third, etc. space.
If yes write it, if no get the next character.
A space can be identified by the ascii value 0x20 or you can also use ' ' as in:
if( c == 0x20 ) . . . or . . . if( c == ' ' ) ...both are equivilent.

- Write desired characters to the outfile.
http://www.cplusplus.com/reference/i...tream/put.html

- Finally you will need to close the files (see open.html's above)
Reply With Quote
Reply

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading a bitmap file wind_addict Game Development 6 08-16-2011 02:29 AM
PRinting a File in C akshaylamba C Programming 0 06-02-2008 11:53 PM
File I/O (Reading from a Random-Access File) VersEtreOuNe C++ Programming 0 02-12-2008 03:39 PM
How to run .exe file from console leoman730 C++ Programming 0 09-30-2006 04:48 AM
getting file icon iwdu15 C# Programming 0 09-29-2006 12:50 AM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 03:02 PM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board