It sounds like you have three distinct problems: How to read a text file with C How to write a text file with C How to process a stream of data Fortunately for you, you have internet access and there are a *ton* of resources for C programming on the internet. Reading a file can be as simple as http://www.phim.unibe.ch/comp_doc/c_manual/C/EXAMPLES/read_file.c Writing is not much more work, using a command such as fputc on an open (for writing) file handle: http://www.phim.unibe.ch/comp_doc/c_manual/C/FUNCTIONS/fputc.html A C reference is here http://www.phim.unibe.ch/comp_doc/c_manual/C/cref.html As far as processing the file itself, there are a number of ways to attack it. If you knew the file was well-defined, and would never have any sequence other than '111' and '000' then you could simply top: read a character into variable c Write from c into the output file read a character into variable c read a character into variable c goto top It's cheating, in a sense, but whether it's acceptable depends on your data. You didn't tell us what your program needed to do in the case that there are only two 1's, 0's, or a single 1 or 0 - whether those are output as well, or cause a error to be displayed, or ignored, etc. I could go on with many, many solutions, but none of them may work, or all of them may work. I can't tell, since you haven't given us a complete specification. Also- read up on the use of eof(). It's important to know when the file ends and stop reading from it. -Adam ali dawji wrote: > Dear Sir. > I am a new beginner in c language, and I have a problem as follow: > I have a file (f1.txt) with data for example: > > 000111111000111000000000111111000??? > > I want to read this file and save the result in other file, called > (f2.txt), > the reading procedure is as follow: > 1-every three zeros change to one 0. > 2-every three ones change to one 1. > So the result of the file (f2.txt) should be as: > 01101000110? > > Any help is welcomed. -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.