I can type s at the start and it scans. at the end, however, i get:Code:#include <iostream> #include <string> #include <cstdlib> #include <stdlib.h> #include <windows.h> #include <stdio.h> #include <time.h> using namespace std; int Wait ( int Seconds ); int main ( void ) { char scan; while (scan != 'n') { string a("Norton anti virus scanning \n"); string c("7 Hits\n"); string d("Viruses found: 4\n"); string e("Code red Worm\n"); string f("Nimda Virus\n"); string g("Love Bug Virus\n"); string h("Kevlarsmart Worm\n"); string j("Trojans: 3\n"); system("cls"); cout << "scan system? Y or N: "; cin >> scan; cout << a; Wait (5); cout << c; Wait(3); cout << d; cout << e; cout << f; cout << g; cout << h; cout << "No files fixed\n"; Wait(2); cout << j; cout << "No files fixed\n"; Wait(4); cout << "Scan again? Y or N: "; cin >> scan; { while (scan != 'y' or 'n') cout << "Invalid command"; Wait(2); return 0; } } } int Wait ( int Seconds ) { clock_t endtime = clock() + Seconds * CLOCKS_PER_SEC; while ( ( clock() < endtime ) ); return 0; }
Invalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid
Forever and ever.
No matter what i type.
Should i use a goto loop, a while loop, or if, or what?
How can i fix that?
It looks like this at the end:
_________________________________
_________________________________
Scan again? Y or N: n
Invalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid
Invalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid commandInvalid
_____________________________
_____________________________