ZikO wrote:
using namespace std;
You should be more specific what namespaces you use. For example:
using std::cout;
using std::endl;
using std::string;
etc.
Or remove the "using" part complitely and within your code, use directly:
std::string name1, name2;
etc.
This might have advantage if some day you or someone working with your
code needs to use their own namespace with your code.
string create_name(const string &orginal);
As you are writing C++, you could use more classes, instead of just
functions. But if classes are too advanced for you now, you could use
more functions. Currently you have too much code in your main() function.
const char *p_name1 = name1.c_str();
const char *p_name2 = name2.c_str();
Looks like you could live without these two variables. I see no
advantage in using them.
ofstream out(p_name2);
You don't check that you can actually write to that file. If file is
write protected, program will continue and print no error about the
situation.
int last = sn.size();
last seems not be used anywhere
size_t current = sn.rfind('.');
if( current != string::npos )
sn.insert(current, tag);
sn = orginal + tag;
The above 4 lines could be written with single line, because what ever
is set to sn, the 4. line will overwrite it.
sn = orginal + tag;
.
|