C++实现查询天气预报 | 您所在的位置:网站首页 › 查明天天气预报情况怎么写 › C++实现查询天气预报 |
C++实现查询天气预报
一、新的变化
二、用到的API接口
三、用到的函数
四、sqlite教程
五、Jsoncpp教程
六、代码
七、程序运行截图
八、其他附件
原地址:http://blog.csdn.net/x_iya/article/details/8583015 一、新的变化1、使用的开发环境是VS 2019 2、原程序中使用的很多API接口已经失效,对API进行了更新 3、对程序输出进行了简单改写,可以循环查询城市天气 二、用到的API接口1、本机IP查询: http://ip.dnsexit.com/ 2、IP相关信息查询: http://ip-api.com/json/?lang=zh-CN&ip=IP地址 3、天气相关信息查询: http://api.help.bj.cn/apis/weather/?id=城市代码 三、用到的函数1、sqlite 通过城市名称利用sqlite3查询城市代号 2、Jsoncpp 对IP信息和天气信息进行处理 3、C++中GB2312字符串和UTF-8之间的转换:http://blog.csdn.net/lgh1992314/article/details/8579206 四、sqlite教程1、下载地址: https://www.sqlite.org/download.html 2、sqlite菜鸟教程: https://www.runoob.com/sqlite/sqlite-tutorial.html 3、sqlite配置下载安装教程:https://www.cnblogs.com/weibanggang/p/9478492.html 4、如何在Windows 10上构建SQLite3.lib文件:https://blog.csdn.net/m0_37909265/article/details/105102982 5、sqlite可视化工具: http://sqliteadmin.orbmu2k.de/ 五、Jsoncpp教程1、下载地址: https://sourceforge.net/projects/jsoncpp/ 2、windows下JSonCpp的编译和使用: https://www.cnblogs.com/hpcpp/p/7889456.html 3、使用 C++ 处理 JSON 数据交换格式:http://blog.csdn.net/lgh1992314/article/details/8582179 4、JsonCpp中文unicode编码问题: http://blog.csdn.net/x_iya/article/details/16833663 六、代码 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include "include/sqlite/sqlite3.h" #include "include/json/json.h" #pragma comment(lib,"sqlite3.lib") #pragma comment(lib,"json_vc71_libmtd.lib") using namespace Json; using namespace std; std::string City_code; std::string country; std::string city; std::string province; std::string isp; int sqlite3_exec_callback(void* data, int n_columns, char** col_values, char** col_names) //sqlite数据库的回调函数 { //int i; /*for(i=0; i < n_columns; i++) { cout content += wstr; } wfin.close(); system("del temp.json"); //std::wcout.imbue(std::locale("")); //std::wcout |
CopyRight 2018-2019 实验室设备网 版权所有 |