Forum Thread: Why Doesnt This Work? C++

#include <iostream>
#include <Windows.h>
#include <string>
using namespace std;

int main() {
string target = "";
string perform = "false";
string yesOrnow = "N";
string ip;
system("color a");

cout << "Please enter the ip of the target: \n";
cin >> target;
Sleep(1000);
cout << "Do you wanna start the attack now? (Y/N) ";
cin >> yesOrnow;

if (yesOrno == "Y") {
perform = "true";
system("color a");
cout << "Setting up..." << endl;
}
else {
cout << "Pausing!";
system("pause");
}

while (perform != "false") {
ip << "ping " << target << " -t";
system(ip.str().c_str());
system("cls");
}
}

5 Responses

I dont know anything about c++ but maybe the line YesorNow?? I think that should be yesorno

why its not working, if you are in python 3.2 you need to convert Windows.h to window.h, i think

When you check the string variable yesOrnow for a "Y" character, you don't actually check the variable due to mispelling.

Also, consider trying to learning gdb for debugging.

What is the error your compiler throws? It looks like you have a typo with the YesOrNo variable. One line it's YesOrNow, next you're running an if statement on YesOrNo. Also you may want to consider that the user may not input a Y or an N.

Share Your Thoughts

  • Hot
  • Active