![]() |
|
#1
|
|||
|
|||
Finding how to get the combinations right?Hello, I need some help on my code.
I have to create a program that reads in characters until the user enters the correct two-character sequence= (cs) to open door. Sample Data: cs = Door opens ccs=Door opens fkcds=Door doesn't open kasfcsgd=Door opens I have to use While Loop. but I need HELP what to put in right. MY CODE: CPP / C++ / C Code:
***The code doesn't really go that great. When I enter fgscs. It says Access Denied then Access Accepted. When I enter fsggs, It says Access Accepted. I dont get it. PLZZ HELP*** |
|||
|
#2
|
|||
|
|||
Re: Finding how to get the combinations right?Sorry I got it working, but when I put the Sample Data like: asfgdcs. It says Access Denied like 7 or 6 times. then it says Access Accepted.
The New code I made is right but It says Access Denied and then, like if you entered afscs. then it says Access Accepted, If you put sdgsf: then it would say Access Denied then Enter Password again until you get it. It works, but I need help getting the Access Denied removed. MY NEW CODE CPP / C++ / C Code:
|
|
#3
|
|||
|
|||
Re: Finding how to get the combinations right?CPP / C++ / C Code:
So when you enter something like "sfsdfsdio", here's what happens: Your program reads one character at a time and tests whether that character equals first. If it does not, it reads the second and so on. It never reads the entire line and thus cannot compare the entire line. And the test in your while () works like this: IF mem NOT first AND IF second Since second is non-zero, it is always true, but your program doesn't test mem against second at any point. If you want to do it with chars, you need two of them. Then you need to could make up some pretty compicated structure for testing etc. Or, you could strings, since such a facility is there for you to freely use. I would do it with something as follows: CPP / C++ / C Code:
Not sure if it compiles on your compiler though, since you are using iostream.h and void main() in your code.. If it doesn't compile, you need a more recent compiler. |
|
#4
|
|||
|
|||
Re: Finding how to get the combinations right?Thanx alot!
I got it now!!! ![]() |
|
#5
|
|||
|
|||
Re: Finding how to get the combinations right?Quote:
|
|
#6
|
|||
|
|||
Re: Finding how to get the combinations right?Quote:
The code I got is the code you posted ??? So, I don't really need to put mine ? |
|
#7
|
|||
|
|||
Re: Finding how to get the combinations right?Quote:
|
Recent GIDBlog
Install Adobe Flash - Without Administrator Rights by LocalTech
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| combinations | cpit | C++ Forum | 5 | 14-Oct-2006 11:31 |
| Need help in finding adsense ID | Paramesh | AdSense Forum | 3 | 19-Feb-2006 14:56 |
| Finding mode in array of numbers | Snowcat | C++ Forum | 3 | 18-Jan-2006 07:57 |
| [c++] number combinations | balusss | C++ Forum | 8 | 11-Dec-2005 22:41 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The