decoding a text file to another by changing the characters of the strings in the file to another specific characters
<p>I'm interested to take two text files using the argument vectors the first one as an input and the second as an output (empty/blank file) ,then decode the input file by changing <strong>Words</strong> (words- considered to contain only characters) or the letters of the word to "a" by the same number of letters,<strong>Numbers</strong> by changing each digit to "0", <strong>anything else</strong> (letters,numbers and punctuation) to "x". and copy the decoded to the output file keeping the same number of spaces and lines BETWEEN each string (word,number and mixed).</p>

<p>Note: The lines of the input shouldn't be limited !!</p>

<p>The Problem:</p>

<p>Frankly, i wrote something and it works partially, after reading each string and do the decoding, and copying the decoded to the output file it doesn't enter a line after finishing 
each line, so the program prints all the strings continuously decoded as wanted in the same
line.</p>

<p>Here is the code:</p>

<pre><code>void read_line(ifstream &amp;inp_f,ofstream &amp;out_f)
{
    char c,
        str[MAX_STR_LEN],// holds the string that working on
        prev_str[MAX_STR_LEN]; // holds the previous string
    int count_spaces=-1,
        count_entered=0, // how many chars are in the array including '\0'
        counter[CNTR_LEN];// holds the number of each type of string in the line
    bool read=false,copy=false;

    while(!inp_f.eof())
    {
        c=inp_f.get();

        if(!isspace(c) &amp;&amp; c!='\n')
        {
            str[count_entered]=c;
            count_entered++;
            read=true;// only if something has been read except spaces in the line
            copy=true;// used to give the command to copy the char to the string array
        }
        else if(isspace(c) || c=='\n')// when reading a space or one line
        {
            count_spaces++;

            str[count_entered]='\0';

            if(copy &amp;&amp; strcmp(prev_str,str)!=0)
            {
                strcpy(prev_str,str);
                decode(counter,str);// Decoding the string considering it's type
                copy_str(count_spaces,str,counter,out_f); // when all the string has been read,copy it to the output file
                count_entered=0;
                count_spaces=0;
                copy=false;
            }
            ///////////////// can't take it to enter here /////////////////////////
            else if((!copy || !read) &amp;&amp; c=='\n') // when finishing one line
            {
                out_f &lt;&lt; endl;
                // print how many strings there of each type in the current line
                cout &lt;&lt; counter[0] &lt;&lt; " " &lt;&lt; counter[1] &lt;&lt; " "
                     &lt;&lt; counter[2] &lt;&lt; endl;

                // re-initial the counters for the next line!
                for(int i=0;i&lt;CNTR_LEN;i++)
                {
                    counter[i]=0;
                }
            }
        }
    }
}
</code></pre>

<p>for instance:</p>

<p>input:</p>

<blockquote>
  <p>unknown human species living just 11500 years ago are identified in southern China,
  which discovered in 15/03/12 or the 3rd of last month</p>
</blockquote>

<p>output:</p>

<blockquote>
  <p>aaaaaaa aaaaa aaaaaaa aaaaaa aaaa 00000 aaaaa aaa aaa aaaaaaaaaa aa aaaaaaaa xxxxxx
  aaaaa aaaaaaaaaa aa xxxxxxxx aa aaa xxx aa aaaa aaaaa</p>
</blockquote>
