Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Use exit() Very Carefully The use of the exit() function may bypass cleanup functions. In C++ you can avoid the exit() function by throwing and catching exceptions, in C there is an error handling capability using setjmp() and longjmp(). Generally setjmp() would be used in main() and longjmp would be used where error conditions happening. This stackoverflow.com question discusses setjmp() and longjmp(). This stackoverflow.com question discusses setjmp() and longjmp().

Use exit() Very Carefully The use of the exit() function may bypass cleanup functions. In C++ you can avoid the exit() function by throwing and catching exceptions, in C there is an error handling capability using setjmp() and longjmp(). Generally setjmp() would be used in main() and longjmp would be used where error conditions happening. This stackoverflow.com question discusses setjmp() and longjmp().

Use exit() Very Carefully The use of the exit() function may bypass cleanup functions. In C++ you can avoid the exit() function by throwing and catching exceptions, in C there is an error handling capability using setjmp() and longjmp(). Generally setjmp() would be used in main() and longjmp would be used where error conditions happening. This stackoverflow.com question discusses setjmp() and longjmp().

Bounty Awarded with 50 reputation awarded by mnoronha
Corrected typos and errors in the answer, made it more readable.
Source Link
pacmaninbw
  • 26.1k
  • 13
  • 47
  • 113

setupCursesForSnake(). setupDisplay(). setupUserLevel(). playSnake(). cleanup().

  • setupCursesForSnake().
  • setupDisplay().
  • setupUserLevel().
  • playSnake().
  • cleanup().

In the function moveSnake() The code within the if clause and theelse clause shouldcould be functions functions to simplify the moveSnake() function.

typedef enum {BEGINNER, INTERMEDIATE, EXPERT} PlayerLevel;
PlayerLevel playerLevel = INTERMEDIATE;
 switch(highlightplayerLevel){
 case BEGINNER:
 usDelay = BEGINNER_DELAY;
 halfdelay(BEGINNER_HALF_DELAY);
 break;
 case INTERMEDIATE:
 usDelay = INTERMEDIATE_DELAY;
 halfdelay(INTERMEDIATE_HALF_DELAY);
 break;
 case EXPERT:
 usDelay = EXPERT_DELAY;
 halfdelay(EXPERT_HALF_DELAY);
 break;
 }

setupCursesForSnake(). setupDisplay(). setupUserLevel(). playSnake(). cleanup().

In the function moveSnake() The code within the if clause and theelse clause should be functions to simplify the moveSnake() function.

typedef enum {BEGINNER, INTERMEDIATE, EXPERT} PlayerLevel;
PlayerLevel playerLevel = INTERMEDIATE;
 switch(highlight){
 case BEGINNER:
 usDelay = BEGINNER_DELAY;
 halfdelay(BEGINNER_HALF_DELAY);
 break;
 case INTERMEDIATE:
 usDelay = INTERMEDIATE_DELAY;
 halfdelay(INTERMEDIATE_HALF_DELAY);
 break;
 case EXPERT:
 usDelay = EXPERT_DELAY;
 halfdelay(EXPERT_HALF_DELAY);
 break;
 }
  • setupCursesForSnake().
  • setupDisplay().
  • setupUserLevel().
  • playSnake().
  • cleanup().

In the function moveSnake() The code within the if clause and theelse clause could be functions to simplify the moveSnake() function.

typedef enum {BEGINNER, INTERMEDIATE, EXPERT} PlayerLevel;
PlayerLevel playerLevel = INTERMEDIATE;
 switch(playerLevel){
 case BEGINNER:
 usDelay = BEGINNER_DELAY;
 halfdelay(BEGINNER_HALF_DELAY);
 break;
 case INTERMEDIATE:
 usDelay = INTERMEDIATE_DELAY;
 halfdelay(INTERMEDIATE_HALF_DELAY);
 break;
 case EXPERT:
 usDelay = EXPERT_DELAY;
 halfdelay(EXPERT_HALF_DELAY);
 break;
 }
Remove statement about comprehensive review.
Source Link
pacmaninbw
  • 26.1k
  • 13
  • 47
  • 113

I will not cover anything that B. Wolf has already covered. I'm also sorry that this could not be more comprehensive, I have not reviewed all the functions.

I will not cover anything that B. Wolf has already covered. I'm also sorry that this could not be more comprehensive, I have not reviewed all the functions.

I will not cover anything that B. Wolf has already covered.

deleted 66 characters in body
Source Link
pacmaninbw
  • 26.1k
  • 13
  • 47
  • 113
Loading
Source Link
pacmaninbw
  • 26.1k
  • 13
  • 47
  • 113
Loading
lang-c

AltStyle によって変換されたページ (->オリジナル) /