Re: Couting lines.



 DEVELOP > c-Plus-Plus > Re: Couting lines.

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1
Topic: DEVELOP > c-Plus-Plus
User: "Aggro"
Date: 12 Sep 2006 04:02:14 PM
Object: Re: Couting lines.
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;
.

 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER