c++ program to use nmap

#include <iostream>
#include <string>
#include <cstdlib>

int main() {
    // Define the command to run Nmap and the target IP address
    std::string command = "nmap ";
    std::string targetIP = "127.0.0.1";  // Replace with the target IP address

    // Concatenate the command and target IP
    std::string fullCommand = command + targetIP;

    // Use the system() function to execute the Nmap command
    int result = system(fullCommand.c_str());

    // Check the result of the system() function
    if (result == 0) {
        std::cout << "Nmap scan completed successfully." << std::endl;
    } else {
        std::cout << "Nmap scan failed. Please check your Nmap installation." << std::endl;
    }

    return 0;
}