a c++ error

I created this code so that it would code anthing inside of a file that you have.
heres the code with cin instead of a file, it works. after that is the code with the file that should run

#include <iostream>
#include <string>
#include <fstream>

using namespace std;

string subb;
int x;

int main()
{
char filename[50];
cout<<"Welcome to codemaker! please put the file that you would\nlike to code in the file that this came with.";
cout<<"\n\nWhat is the name of your file?";
cin>>filename;
ifstream openfile;
openfile.open(filename);
string code[10000];
for(int u=0; u<10000; u++)
{
getline(openfile, code[u]);
x=code.length();
for (int z=0; z<=x; z++)
{
subb.assign(code.substr(z,1));
if (subb=="a")
{
code.replace(z, 1, "c");
}
if (subb=="c")
{
code.replace(z, 1, "e");
}
if (subb=="e")
{
code.replace(z, 1, " ");
}
if (subb=="g")
{
code.replace(z, 1, "i");
}
if (subb=="i")
{
code.replace(z, 1, "k");
}
if (subb=="k")
{
code.replace(z, 1, "m");
}
if (subb=="m")
{
code.replace(z, 1, "o");
}
if (subb=="o")
{
code.replace(z, 1, "q");
}
if (subb=="q")
{
code.replace(z, 1, "s");
}
if (subb=="s")
{
code.replace(z, 1, "u");
}
if (subb=="u")
{
code.replace(z, 1, "w");
}
if (subb=="w")
{
code.replace(z, 1, "y");
}
if (subb=="y")
{
code.replace(z, 1, "a");
}
if (subb=="b")
{
code.replace(z, 1, "d");
}
if (subb=="d")
{
code.replace(z, 1, "f");
}
if (subb=="f")
{
code.replace(z, 1, "h");
}
if (subb=="h")
{
code.replace(z, 1, "j");
}
if (subb=="j")
{
code.replace(z, 1, "l");
}
if (subb=="l")
{
code.replace(z, 1, "n");
}
if (subb=="n")
{
code.replace(z, 1, "p");
}
if (subb=="p")
{
code.replace(z, 1, "r");
}
if (subb=="r")
{
code.replace(z, 1, "t");
}
if (subb=="t")
{
code.replace(z, 1, "v");
}
if (subb=="v")
{
code.replace(z, 1, "x");
}
if (subb=="x")
{
code.replace(z, 1, "z");
}
if (subb=="z")
{
code.replace(z, 1, "b");
}
if (subb==" ")
{
code.replace(z, 1, "g");
}
}
}
openfile.close;

ofstream savefile(filename);
{
for (int up=0; up<=u; up++)
{
savefile<< code[up];

}
}
}


#include <iostream>
#include <string>
#include <fstream>

using namespace std;

string subb;
int x;

int main()
{
char filename[50];
cout<<"Welcome to codemaker! please put the file that you would\nlike to code in the file that this came with.";
cout<<"\n\nWhat is the name of your file?";
cin>>filename;
ifstream openfile;
openfile.open(filename);
string code[10000];
for(int u=0; u<10000; u++)
{
getline(openfile, code[u]);
x=code.length();
for (int z=0; z<=x; z++)
{
subb.assign(code.substr(z,1));
if (subb=="a")
{
code.replace(z, 1, "c");
}
if (subb=="c")
{
code.replace(z, 1, "e");
}
if (subb=="e")
{
code.replace(z, 1, " ");
}
if (subb=="g")
{
code.replace(z, 1, "i");
}
if (subb=="i")
{
code.replace(z, 1, "k");
}
if (subb=="k")
{
code.replace(z, 1, "m");
}
if (subb=="m")
{
code.replace(z, 1, "o");
}
if (subb=="o")
{
code.replace(z, 1, "q");
}
if (subb=="q")
{
code.replace(z, 1, "s");
}
if (subb=="s")
{
code.replace(z, 1, "u");
}
if (subb=="u")
{
code.replace(z, 1, "w");
}
if (subb=="w")
{
code.replace(z, 1, "y");
}
if (subb=="y")
{
code.replace(z, 1, "a");
}
if (subb=="b")
{
code.replace(z, 1, "d");
}
if (subb=="d")
{
code.replace(z, 1, "f");
}
if (subb=="f")
{
code.replace(z, 1, "h");
}
if (subb=="h")
{
code.replace(z, 1, "j");
}
if (subb=="j")
{
code.replace(z, 1, "l");
}
if (subb=="l")
{
code.replace(z, 1, "n");
}
if (subb=="n")
{
code.replace(z, 1, "p");
}
if (subb=="p")
{
code.replace(z, 1, "r");
}
if (subb=="r")
{
code.replace(z, 1, "t");
}
if (subb=="t")
{
code.replace(z, 1, "v");
}
if (subb=="v")
{
code.replace(z, 1, "x");
}
if (subb=="x")
{
code.replace(z, 1, "z");
}
if (subb=="z")
{
code.replace(z, 1, "b");
}
if (subb==" ")
{
code.replace(z, 1, "g");
}
}
}
openfile.close;

ofstream savefile(filename);
{
for (int up=0; up<=u; up++)
{
savefile<< code[up];

}
}
}
closed account (zb0S216C)
First thing's first: Can you please surround your code with code tags? It's so hard to read. Secondly, where does your compiler say your error resides? To be perfectly honest, I don't want to go reading through your code without knowing what I'm looking for.

Also, did you post your code twice? It looks it to me.

Wazzak
@Framework - completly agree with you in all aspects!

@OP (original Poster) - It would be better if you post this program using the "code" tags given the "FORMAT" part on the RHS of the typing text box. Secondly no need to repost again ! just edit it by using the "EDIT" button!

Also do tell in which line are you facing the trouble because even if you do tell that WE will not count the lines in your program just to reach the error line. And do tell what error does the compiler give and what do you want this program to do and what is your desired output. Also your program is toooooo BIG. Check (as framework said) whether u have messed up the programming code while pasting it!

hope you do the needy and in-turn help yourself possibly quicker!!
Topic archived. No new replies allowed.