I started this code, and it does encode the text, however it only does the first line of text and repeats it. It is also encoding spaces.

#include <fstream>
#include <iostream>
#include <string>
using namespace std;

int main()
  ifstream fin;

  string fileName;
  cout << "What file do you want to use for input? ";
  getline(cin, fileName);

  string s;

while (true)
    if (!fin.good()) break;
    getline(fin, s);
        string s = "Hello, World"; // an example
    for (int i = 0; i < s.length(); i++) // for each char in the string...
    cout << s << endl;


   return 0;

Lines 20 and 21. You have two strings named s with different scopes. You have read a line from the file and stuck that line into one of them in line 20, then you have placed "Hello, World" into the other one in line 21, then on lines 22 and 23, you are manipulating string s. But do you know WHICH string s you are manipulating? I fail to see the need for the string on line 21 anyway. You're reading from a file, right?

As far as manipulating spaces when you don't want, check out the cctype library. You can test what kind of character a character is and act accordingly (i.e. manipulate only printable characters). An "if" statement combined with a function from cctype, then placing line 23 within the code to execute if the if statement is true might be what you are looking for.

This question has already been answered. Start a new discussion instead.