Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualSubtle_Wonders

Posted 14 February 2013 - 11:16 AM

One idea is to not fork a new process just to wait for input from a user. Simply using std::cin.get() should suffice:

 

 
void wait() {
    cout << "Press return key to continue...";
    cin.get();
}

Bonus: this code is completely cross platform, and actually does the same thing on all platforms (in contrast, pause and sleep 1 do not do the same thing).

 

There are lots of non-performance related improvements. Some of your variable names are very poor, "x" and "y" in particular. Your use of the first element of the "sum" array as two unrelated temporary values is very confusing.

 

Overall, the intent behind the program is not really shining through the code. It is difficult to assess it's correctness without knowing what is supposed to be happening.

Never thought about that!  Thanks a bunch!  You do have some valid points and I can definately concor with your concerns. Two things learned from such a simple code post.  This is bloodly awesome.  biggrin.png   I'm doing this more often. hahaha!


#1Subtle_Wonders

Posted 14 February 2013 - 11:15 AM

One idea is to not fork a new process just to wait for input from a user. Simply using std::cin.get() should suffice:

 

 
void wait() {
    cout << "Press return key to continue...";
    cin.get();
}

Bonus: this code is completely cross platform, and actually does the same thing on all platforms (in contrast, pause and sleep 1 do not do the same thing).

 

There are lots of non-performance related improvements. Some of your variable names are very poor, "x" and "y" in particular. Your use of the first element of the "sum" array as two unrelated temporary values is very confusing.

 

Overall, the intent behind the program is not really shining through the code. It is difficult to assess it's correctness without knowing what is supposed to be happening.

Never thought about that!  Thanks a bunch!  You do have some valid points and I can definately concor with your concerns. Two things learned from such a simply code post.  This is bloodly awesome.  biggrin.png   I'm doing this more often. hahaha!


PARTNERS