首页 > 其他 > 详细

Qt 域名转成IP

时间:2014-04-08 12:43:54      阅读:1238      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
#include <stdio.h>
#include <stdlib.h>
#include <netdb.h>
#include <arpa/inet.h>
struct
hostent *h; QByteArray ba = ui->lineEdit->text().toLatin1(); h = gethostbyname(ba.data()); if(h == NULL) { qDebug()<<"get hostbyname error!"; exit(1); } struct in_addr *in=(in_addr *)h->h_addr; char *ch = inet_ntoa(*in); QString str = QString(QLatin1String(ch)); qDebug()<<"IP Address:"<<str; ui->lineEdit_2->setText(str);
bubuko.com,布布扣

 

Qt 域名转成IP,布布扣,bubuko.com

Qt 域名转成IP

原文:http://www.cnblogs.com/wiessharling/p/3650982.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!