0

hola tengo el siguiente programa ,por favor quisiera que me ayudaran a corregir el error,me aparece ? "ping" no se reconoce como un comando interno o externo, programa o archivo por lotes ejecutable.

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

int main() {


    int dato; 
    cout << "ingrese datos:";
    cin >> dato;

    char url; 
    cout << "ingrese url:";
    cin >> url;
 
    stringstream comando;
    comando << "ping " << url;

    for (int i = 0; i < dato; ++i)
    {
        system(comando.str().c_str());
    }
 
    return 0;
}
2
  • Ese no es un error con tu programa. Tienes disponible el comando en tu terminal? el 5 may. 2021 a las 16:06
  • no ,gracias ya lo pude solucionar el 10 may. 2021 a las 14:28

1 respuesta 1

0

Prueba con esto

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

int main() {


    int dato; 
    cout << "ingrese datos:";
    cin >> dato;

    string url; 
    cout << "ingrese url:";
    cin >> url;
 
    string comando;
    comando="ping "+url;
    for (int i = 0; i < dato; ++i)
    {
        system(comando.c_str());
    }
 
    return 0;
}

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.