Re: Code critique
> This should be avoided, but is not terrible, particularly for small[color=blue]
> programs. Generally, import only what you need where you need it, so you
> could use
>
> using std::string;
> using std::vector;
>[/color]
Unfortunately MSVC 6 does not implement this usage correctly.
[color=blue]
> and you could even put these inside the functions that use those items.
>[/color]
Has E Robert Tisdale got to you? It's not advice I would give.
[color=blue][color=green]
> >
> > const string KSeqFile = "collatz.tx t";
> > const unsigned KCheckInterval = 10000000;[/color]
>
> This value is much too large to portably put in an unsigned int. The
> portable maximum for unsigned int is 65535. Better make it unsigned long.
>[color=green]
> >
> > //-----------------------------------------------
> >
> > void awaitEnter()
> > {
> > char c[2];
> > cout << "Program finished. Hit <Enter> to close.";
> > cin.getline(c, 2);
> > }
> >
> > bool prompt(const string& message)
> > {
> > char c;
> > cout << message << " (y/n <Enter>) ";
> > cin >> c;
> > #ifdef WIN32
> > cin.ignore(); // Swallow Windows newline's second character.
> > #endif[/color]
>
> Eh? I don't think this is right. This should be the same, Windows or
> not. Besides that, you can't control how many characters are actually
> entered, so you should probably extract the entire line, and check the
> first character.[/color]
This is a well known MSVC 6 bug, it was fixed in a service pack (which the
OP should certainly get hold of) but you can also get this fix and more from
here
john
> This should be avoided, but is not terrible, particularly for small[color=blue]
> programs. Generally, import only what you need where you need it, so you
> could use
>
> using std::string;
> using std::vector;
>[/color]
Unfortunately MSVC 6 does not implement this usage correctly.
[color=blue]
> and you could even put these inside the functions that use those items.
>[/color]
Has E Robert Tisdale got to you? It's not advice I would give.
[color=blue][color=green]
> >
> > const string KSeqFile = "collatz.tx t";
> > const unsigned KCheckInterval = 10000000;[/color]
>
> This value is much too large to portably put in an unsigned int. The
> portable maximum for unsigned int is 65535. Better make it unsigned long.
>[color=green]
> >
> > //-----------------------------------------------
> >
> > void awaitEnter()
> > {
> > char c[2];
> > cout << "Program finished. Hit <Enter> to close.";
> > cin.getline(c, 2);
> > }
> >
> > bool prompt(const string& message)
> > {
> > char c;
> > cout << message << " (y/n <Enter>) ";
> > cin >> c;
> > #ifdef WIN32
> > cin.ignore(); // Swallow Windows newline's second character.
> > #endif[/color]
>
> Eh? I don't think this is right. This should be the same, Windows or
> not. Besides that, you can't control how many characters are actually
> entered, so you should probably extract the entire line, and check the
> first character.[/color]
This is a well known MSVC 6 bug, it was fixed in a service pack (which the
OP should certainly get hold of) but you can also get this fix and more from
here
john
Comment