There are some errors and some things to change:
in the
encChar
function this is wrong:if (flag = true)
. You should use a comparison operator (==
):`if (flag == true)`
Someone prefers this form (comparison terms swapped):
`if (true == flag)`
because wrong assignments are detected.
in the
encFile
function it should be:ofstream destined(outFile.c_str());
It's a good idea to enable warnings (e.g. with GCC/CLANG use
-Wansi -Wall -Wextra
) so that unused variables/parameters are detected (in your case thestring outFile
input parameter).
Pay attention at Simple's advice (Try using an absolute path. It's probably related to your program having a different working directory to what you expect) and your program should work.
You could improve your code with some other changes:
place variables in the narrowest scope possible and initialize variables in the declaration, e.g.
ifstream required; required.open(inFile.c_str());
should be
ifstream required(inFile.c_str());
(and check for error before using the stream).
using namespace std
is considered a bad practice.coding style and formatting are pretty arbitrary, but code is much easier to follow if you always use the same style.