
C & C++
文章平均质量分 51
ivnetware
这个作者很懒,什么都没留下…
展开
-
linux环境下部署MySQL Connector/C++
在编写C/C++程序访问mysql时,可使用MySQL C API或者MySQL++访问MySQL。下面是官网对MySQL C API和MySQL++的介绍:The C API provides low-level access to the MySQL client/server protocol and enables C programs to access database c原创 2016-10-23 13:09:54 · 952 阅读 · 0 评论 -
使用ccl库读取配置文件
下载、编译、安装库.wget http://files.sbooth.org/ccl-0.1.1.tar.gztar -xvf ccl-0.1.1.tar.gzcd ccl-0.1.1./configuremakemake installldconfig测试:在解压后的文件夹,有个demo文件夹,运行以下命令即可进行测试.[root@localhost ccl-0.1.1]# cd d...原创 2018-03-21 18:10:03 · 1454 阅读 · 0 评论 -
通过汇编理解返回char p []和char *p 中P的区别
先看两个程序。test01.cpp/* *filename:test01.cpp */#include char *returnStr(){ char *p = "hello world!"; return p;}int main(){ char *str; str = returnStr(); printf("%s\n", str); return 0;原创 2017-12-17 14:06:13 · 1024 阅读 · 0 评论 -
snmp++ 3.3.7开发包的使用
SNMP++是什么?SNMP++是HP公司开发的一套用于SNMP编程的C++开源库,提供了简单易用的接口,被广泛使用于网络管理的开发。网上有很多snmp++ 3.2.25版本的环境搭建,但snmp++ 3.3.7版本的开发环境搭建稍有不同,特此记录之。snmp++ 于2016年2月29发布了新的版本,针对于C++ API接口的包已经更新到了3.3.7版本。 大家可以从h原创 2016-10-07 13:12:06 · 6778 阅读 · 2 评论 -
inet_addr函数讲解
The inet_addr() function converts the Internet host address cp from IPv4 numbers-and-dots notation into binary data in network byte order。 inet_addr() 函数的作用是将点分十进制的IPv4地址转换成网络字节序列的长整型。网络字节序定原创 2017-12-08 23:44:09 · 13472 阅读 · 5 评论 -
linux socket 缓存
内容来自:http://m.blog.youkuaiyun.com/penzchan/article/details/41653877问题:同时与多个主机建立连接,如果这些主机同时发生数据到本地,本地又没有调用recv接收,会是什么情况?解答:系统为每个socket建立一个缓存,IP层组包进程在收到数据包后会把数据放入socket缓存。应用程序通过socket系统调用和远程主机进行通讯,每一个so转载 2017-10-10 21:56:09 · 1569 阅读 · 0 评论 -
C++ 实现交换机配置自动保存
利用c++写了个通过telnet方式登录至cisco 3550保存交换机配置的程序。源代码可点击telnet_expect下载。原创 2017-03-19 19:00:47 · 955 阅读 · 0 评论 -
linux C++ 获取当前日期时间
新建cdatetime.cpp#include #include #include #include #include using namespace std;string datetime(){ time_t now = time(0);// 基于当前系统的当前日期/时间 tm *ltm = localtime(&now); char iyear[50原创 2016-10-02 16:46:31 · 11747 阅读 · 0 评论 -
输出数个月之前的日期(c++)
本示例是输出3个月前的日期,可以通过更改Month_num的数值来实现指定数月前的日期。/* filename:pdate.cpp description:输出数个月之前的日期*/#include #include using namespace std;const int Month_num = 3; int main( ){ int nYear,nMont原创 2017-01-15 18:30:29 · 628 阅读 · 0 评论 -
C++ 字符串的几种表示方法
1、字符数组(使用初始化列表)char str1[11]={‘c’,’h’,’a’,’r’,’ ‘,’a’,’r’,’r’,’a’,’y’,’\0′};字符数组中显式地包含空字符’\0’; 2、字符数组(使用双引号字符串常量)char str2[11]=”char array”;字符数组隐式包含空字符’\0’;”char array”存储在栈上;原创 2016-12-04 23:08:43 · 5655 阅读 · 1 评论 -
C++ 友元函数和非成员运算符重载
定义友元+运算符函数Box operator+(const Box &b1 ,const Box &b2);友元函数的特点是,可以与成员函数一样具有访问private 成员变量。但友元函数并不是成员函数。创建友元函数的关键在于,将其原型放在类声明中,并在函数名前加上关键字friend。#include using namespace std; class Box{原创 2016-12-11 02:54:02 · 715 阅读 · 0 评论 -
C++ 成员重载运算符
+ 运算符一般用于基本类型的增加,如int,double类型等,也可用于字符串的连接;以下代码演示C++ 对运算符+进行重载,使+ 运算符能用于两个Box类型的变量进行求和操作。#include using namespace std; class Box{ private: int m_length; int m_height; int m_width;原创 2016-12-11 01:08:56 · 542 阅读 · 0 评论 -
C++ 指针和const
一、指针指向的内容不能更改(该处说明是不能通过指针修改,并不是说不能通过变量名修改),如下例子:#include using namespace std; int main(){ int age = 2; const int *n = &age; //定义一个指向整型变量的指针,该指针指向的内容不能变; //*n = 3; 不能通过*n方式去修改,因为上面的const原创 2016-12-11 01:47:09 · 316 阅读 · 0 评论 -
C++ 构造函数、默认构造函数、析构函数和对象初始化
#include using namespace std;class Student{ private: int m_age; int m_grade; string m_sex; public: Student(int age,int grade,string sex); //构造函数原创 2016-12-10 12:37:30 · 3143 阅读 · 0 评论 -
生成含年月日的mysql数据库备份文件
想在linux系统上做一个计划任务,每天23:59分左右对数据库进行备份,备份的文件名中包含当前时间的年月日(如:mydb-back-auto-20161109.sql)。计划任务对应的执行文件如果用shell script写,比较简单,但是,由于是script的原因,代码都是可见的,对数据库进行备份,script中必定包含登录数据的账号和密码,所以利用script简便,但不安全。下面用C原创 2016-11-09 01:04:37 · 747 阅读 · 0 评论 -
使用boost log时,输出的日志文件中TimeStamp为空解决办法
在程序中添加红色部分代码:void init() { boost::log::add_common_attributes(); logging::add_file_log ( keywords::file_name = "sample_%N.log", /**/原创 2016-10-02 13:07:20 · 1884 阅读 · 0 评论 -
boost log 报错undefined reference to boost::log::v2_mt_posix::basic_formatter
在编译boost log文件时报错提示:undefined reference to `boost::log::v2_mt_posix::basic_formatterchar> boost::log::v2_mt_posix::parse_formatterchar>(char const*, char const*)'解决办法:在编译时添加 -lboost_log_set原创 2016-10-01 22:09:55 · 5888 阅读 · 0 评论 -
read读指针自动后移
以下为测试样例cpp文件, 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ...原创 2018-09-08 01:35:50 · 2107 阅读 · 0 评论