Reputation: 81
I want to make a program in C++ that prompt the user to enter a web address and then performs the ping command in the command prompt on that address. In the code, I used the cin command to get the web address into a string variable called n and add it to "ping" in the same variable but, I cannot enter the string into the system function. Here is the code:
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
string ping;
string n;
cout << "Enter the link you want to ping ";
cin >> ping;
n = "ping "+ping;
cout << n;
system(n);
return 0;
}
How can I enter the string from the variable n into the system function?
Upvotes: 1
Views: 158