Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++] Continuous loop is continuous D: - FIXED!

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
TROLOLOLOLOLOLOLOLOLOLOLO
Expert Cheater
Reputation: -1

Joined: 27 Dec 2009
Posts: 100

PostPosted: Sat Feb 27, 2010 4:53 pm    Post subject: [C++] Continuous loop is continuous D: - FIXED! Reply with quote

Code:
// Beeper.cpp : Defines the entry point for the console application.

#include "stdafx.h"
#include <iostream>
#include <windows.h>

int main()
{
   system("TITLE Beeper By CometJack");
   system("COLOR 2");

   for (char chrAns = 'Y'; chrAns == 'Y' || 'y';)
   {
      system("CLS");

      for (short shtNum = 50; shtNum <= 150; shtNum++)
      {
          std::cout << "Frequency level at: " << shtNum*10 << std::endl;
          Beep(shtNum*10, 50);
          if (shtNum == 149)
          {
             std::cout << std::endl;
          }
      }
      std::cout << "Replay? (Y/N)" << std::endl;
      std::cin >> chrAns;
    }
   return 0;
}


I have it to where the user is asked if he/she wants to replay it, now no matter what key is entered it continues to repeat itself. Why is it doing that?


Last edited by TROLOLOLOLOLOLOLOLOLOLOLO on Sat Feb 27, 2010 5:08 pm; edited 1 time in total
Back to top
View user's profile Send private message
FullyAwesome
I post too much
Reputation: 0

Joined: 05 Apr 2007
Posts: 4438
Location: Land Down Under

PostPosted: Sat Feb 27, 2010 5:06 pm    Post subject: Reply with quote

where you have chrAns == 'Y' || 'y';

change it to:

chrAns == 'Y' || chrAns == 'y';

cause you were seeing if 'y' was true, which it is since it's a value > 0.

_________________
Back to top
View user's profile Send private message MSN Messenger
TROLOLOLOLOLOLOLOLOLOLOLO
Expert Cheater
Reputation: -1

Joined: 27 Dec 2009
Posts: 100

PostPosted: Sat Feb 27, 2010 5:07 pm    Post subject: Reply with quote

FullyAwesome wrote:
where you have chrAns == 'Y' || 'y';

change it to:

chrAns == 'Y' || chrAns == 'y';

cause you were seeing if 'y' was true, which it is since it's a value > 0.


Yeah, just got that right before your post. Thanks though.

Sorry I'm a complete n00b at C++ Laughing
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites