0

So I'm trying to make a DoSer program with C++ using system commands. this is a work in progress and I'm pretty new to C++ and I'm trying to use the ping command with a variable in the same line, look at the code and you will realise what I want

#include <iostream>
using namespace std;

int main()
{
    int targ;
    system("color a")
    ;system("title C++ DoSer ")
    ;cout << " What Site/IP Is Your Target?" << endl;
    cin >> targ;
    system("ping");targ("-t -l 65500")
    ;return 0;
}

but it keeps saying "targ cannot be used as a function". please help

Scorch
  • 115
  • 5
  • NOTE: I know I could use batch scripts but I'm using C++ so after I make this part work I can make multiple threads. also I'm skilled at batch and learning C++ for a school project. – Scorch Jun 23 '18 at 05:49
  • 1
    `targ` is an `int`. Why are you trying to use it as a function? Consider learning C++ from a [good C++ book](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – Algirdas Preidžius Jun 23 '18 at 06:00

1 Answers1

0
#include <iostream>
#include <sstream>

using namespace std;

int main()
{
    string targ;

    system("color a");
    system("title C++ DoSer ");
    cout << " What Site/IP Is Your Target?" << endl;
    cin >> targ;

    ostringstream pingData;
    pingData << "ping " << targ << " -t -l 65500";
    system(pingData.str().c_str());

    return 0;
}
Marek R
  • 27,988
  • 5
  • 42
  • 123