0

Correct and incorrect answer help with code .

Hello ! I'm begginer and I want to ask is there a code when I type certain numbers for example 0000 to continue using the program , but if I type 0001 or other numbers that is not 0000 to exit the program ? Sorry fot my English ..

19th Apr 2019, 5:58 AM
sasasa123
3 odpowiedzi
+ 8
Yes you can, you can create an array of characters or string and then compare it std::string str; do { cin >> str; //Statements } while (strcmp(str, "0000") == 0);
19th Apr 2019, 6:05 AM
blACk sh4d0w
blACk sh4d0w - avatar
0
Here's what it looks like on Python import sys inp = int(input()) if inp is not 0000: print("Only 0000 is allowed") sys.exit() else: print("You wrote 0000")
19th Apr 2019, 6:03 AM
Dlite
Dlite - avatar
0
Thanks !
19th Apr 2019, 6:26 AM
sasasa123