我有一个包含 IP 地址的变量。我试图对此进行 nslookup,而不是返回 DNS 名称,但我得到 0。我处于 Linux 环境中。目标IP来自向量(字符串dest_ip =向量[2])。
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <vector>
#include <algorithm>
#include <iterator>
#include <sstream>
using namespace std;
void split(const std::string& str, std::vector<std::string>& v) {
std::stringstream ss(str);
ss >> std::noskipws;
std::string field;
char ws_delim;
while(1) {
if( ss >> field )
v.push_back(field);
else if (ss.eof())
break;
else
v.push_back(std::string());
ss.clear();
ss >> ws_delim;
}
}
int main()
{
string input_line;
while(cin){
getline(cin, input_line);
for(int i=0; input_line[i]; i++)
if(input_line[i] …
Run Code Online (Sandbox Code Playgroud) 现在,当我编译我收到:
/usr/include/mysql/mysql.h:452: error: too many arguments to function int mysql_query(MYSQL*, const char*)
Run Code Online (Sandbox Code Playgroud)
参数是否存在限制mysql.h
,如果存在,我该如何解决?
#include <mysql/mysql.h>
string unknown = "Unknown";
MYSQL *conn;
conn = mysql_init(NULL);
mysql_real_connect(conn, "localhost", "root", "password", "alert", 0, NULL, 0);
mysql_query(conn, "INSERT INTO alert_tbl (alert_srcip, alert_country, alert_destip, alert_desthost, alert_destport, alert_bl) VALUES ('%s','%s','%s','%s','%s','%s')", src_ip,country_code,dest_ip,unknown,dest_prt,blip);
mysql_close(conn);
Run Code Online (Sandbox Code Playgroud)
g++ test.c -o test -lstdc++ -I/usr/include/mysql -L/usr/lib/mysql -lmysqlclient
Run Code Online (Sandbox Code Playgroud)