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...
Well first you need to be able to: - Open two files,, one for reading and another for writing. http://www.cplusplus.com/reference/iostream/ifstream/open.html http://www.cplusplus.com/reference/iostream/ofstream/open.html - Read one character at a time from the infile. http://www.cplusplus.com/reference/iostream/istream/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/iostream/ostream/put.html - Finally you will need to close the files (see open.html's above)