checking code if violates in c++

Why is working on the same position for more than 15 years not a red flag?

Can this function be rewritten with a regex?

Second-rate spelling

Is there a German word for “analytics”?

CBP Reminds Travelers to Allow 72 Hours for ESTA. Why?

What type of postprocessing gives the effect of people standing out

Understanding Kramnik's play in game 1 of Candidates 2018

What is better: yes / no radio, or simple checkbox?

How to count occurrences of Friday 13th

What to do when being responsible for data protection in your lab, yet advice is ignored?

What is the wife of a henpecked husband called?

Whom do I have to contact for a ticket refund in case of denied boarding (in the EU)?

Can you 'upgrade' leather armor to studded leather armor without purchasing the new armor directly?

You'll find me clean when something is full

What if I store 10TB on azure servers and then keep the vm powered off?

How can atoms be electrically neutral when there is a difference in the positions of the charges?

Why might Google Analytics report a sudden, but persistent, drop in bounce rate (70% to 12%)

How to mitigate "bandwagon attacking" from players?

Creature spells vs. ability to convert a permanent into a creature

Waiting for the gravy at a dinner table

Is my plan for fixing my water heater leak bad?

Where is this triangular-shaped space station from?

I am on the US no-fly list. What can I do in order to be allowed on flights which go through US airspace?

Casually inserting sexuality



checking code if violates in c++














0












$begingroup$


Hi all I need a code check up from all C++ experts. Basically, I need make my code not use these restrictions as shown below:
Can you check if I am using while(1)? thank you.




  • No global variables


  • No labels or go-to statements



    No infinite loops, examples include:



  • for(;;)

  • while(1)

  • while(true)

  • do{//code}while(1);

  • No break statements to exit loops


Here is my code:



int main() {

//MARK: For the validation.
int error = 1;

//MARK: For the highest score.
int highestScore = 0;

//MARK: The player structure.
struct Player players[12];

//MARK: The index.
int index;

// MARK: Iterate through all the players.
for (index = 0; index < 12; index++) {

//MARK: Displaying player number.
cout << "nPLAYER #" << (index + 1) << "n";
cout << "n Player name:";
cin >> players[index].playerName;

while (error == 1) {

cout << "n Player's number:";
cin >> players[index].playerNumber;

//MARK: Simple validation to detect the player for entering negative numbers.
if (players[index].playerNumber < 0) {
cout << "n No negative numbers pleasen";
continue;
}
cout << "n Points scored: ";
cin >> players[index].playerPoints;

if (players[index].playerPoints < 0) {
cout << "n No negative numbers pleasen";
continue;
}
cin.clear();
error = 0;

}

error = 1;

}








share







New contributor




Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$

















    0












    $begingroup$


    Hi all I need a code check up from all C++ experts. Basically, I need make my code not use these restrictions as shown below:
    Can you check if I am using while(1)? thank you.




    • No global variables


    • No labels or go-to statements



      No infinite loops, examples include:



    • for(;;)

    • while(1)

    • while(true)

    • do{//code}while(1);

    • No break statements to exit loops


    Here is my code:



    int main() {

    //MARK: For the validation.
    int error = 1;

    //MARK: For the highest score.
    int highestScore = 0;

    //MARK: The player structure.
    struct Player players[12];

    //MARK: The index.
    int index;

    // MARK: Iterate through all the players.
    for (index = 0; index < 12; index++) {

    //MARK: Displaying player number.
    cout << "nPLAYER #" << (index + 1) << "n";
    cout << "n Player name:";
    cin >> players[index].playerName;

    while (error == 1) {

    cout << "n Player's number:";
    cin >> players[index].playerNumber;

    //MARK: Simple validation to detect the player for entering negative numbers.
    if (players[index].playerNumber < 0) {
    cout << "n No negative numbers pleasen";
    continue;
    }
    cout << "n Points scored: ";
    cin >> players[index].playerPoints;

    if (players[index].playerPoints < 0) {
    cout << "n No negative numbers pleasen";
    continue;
    }
    cin.clear();
    error = 0;

    }

    error = 1;

    }








    share







    New contributor




    Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $endgroup$















      0












      0








      0





      $begingroup$


      Hi all I need a code check up from all C++ experts. Basically, I need make my code not use these restrictions as shown below:
      Can you check if I am using while(1)? thank you.




      • No global variables


      • No labels or go-to statements



        No infinite loops, examples include:



      • for(;;)

      • while(1)

      • while(true)

      • do{//code}while(1);

      • No break statements to exit loops


      Here is my code:



      int main() {

      //MARK: For the validation.
      int error = 1;

      //MARK: For the highest score.
      int highestScore = 0;

      //MARK: The player structure.
      struct Player players[12];

      //MARK: The index.
      int index;

      // MARK: Iterate through all the players.
      for (index = 0; index < 12; index++) {

      //MARK: Displaying player number.
      cout << "nPLAYER #" << (index + 1) << "n";
      cout << "n Player name:";
      cin >> players[index].playerName;

      while (error == 1) {

      cout << "n Player's number:";
      cin >> players[index].playerNumber;

      //MARK: Simple validation to detect the player for entering negative numbers.
      if (players[index].playerNumber < 0) {
      cout << "n No negative numbers pleasen";
      continue;
      }
      cout << "n Points scored: ";
      cin >> players[index].playerPoints;

      if (players[index].playerPoints < 0) {
      cout << "n No negative numbers pleasen";
      continue;
      }
      cin.clear();
      error = 0;

      }

      error = 1;

      }








      share







      New contributor




      Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $endgroup$




      Hi all I need a code check up from all C++ experts. Basically, I need make my code not use these restrictions as shown below:
      Can you check if I am using while(1)? thank you.




      • No global variables


      • No labels or go-to statements



        No infinite loops, examples include:



      • for(;;)

      • while(1)

      • while(true)

      • do{//code}while(1);

      • No break statements to exit loops


      Here is my code:



      int main() {

      //MARK: For the validation.
      int error = 1;

      //MARK: For the highest score.
      int highestScore = 0;

      //MARK: The player structure.
      struct Player players[12];

      //MARK: The index.
      int index;

      // MARK: Iterate through all the players.
      for (index = 0; index < 12; index++) {

      //MARK: Displaying player number.
      cout << "nPLAYER #" << (index + 1) << "n";
      cout << "n Player name:";
      cin >> players[index].playerName;

      while (error == 1) {

      cout << "n Player's number:";
      cin >> players[index].playerNumber;

      //MARK: Simple validation to detect the player for entering negative numbers.
      if (players[index].playerNumber < 0) {
      cout << "n No negative numbers pleasen";
      continue;
      }
      cout << "n Points scored: ";
      cin >> players[index].playerPoints;

      if (players[index].playerPoints < 0) {
      cout << "n No negative numbers pleasen";
      continue;
      }
      cin.clear();
      error = 0;

      }

      error = 1;

      }






      c++





      share







      New contributor




      Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 1 min ago









      MikeMike

      11




      11




      New contributor




      Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "196"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Mike is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f214739%2fchecking-code-if-violates-in-c%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Mike is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Mike is a new contributor. Be nice, and check out our Code of Conduct.













          Mike is a new contributor. Be nice, and check out our Code of Conduct.












          Mike is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Code Review Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f214739%2fchecking-code-if-violates-in-c%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          is 'sed' thread safeWhat should someone know about using Python scripts in the shell?Nexenta bash script uses...

          How do i solve the “ No module named 'mlxtend' ” issue on Jupyter?

          Pilgersdorf Inhaltsverzeichnis Geografie | Geschichte | Bevölkerungsentwicklung | Politik | Kultur...