自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

cozzw

心有所想,眼有所见

  • 博客(23)
  • 资源 (4)
  • 问答 (1)
  • 收藏
  • 关注

原创 共享内存

共享内存:最快的IPC对象,不借助第三方,可被多个进程直接访问写共享内存wshm.cc#include #include using namespace std;#define VERIFY(a,b)\if(a)\{\coutexit(-1);\}\else\coutint main(int argc, char* argv[])

2013-03-18 17:48:31 610

原创 信号量

信号完成进程控制。同步:禁止生产者向满的缓冲区输送产品,禁止消费者向空的缓冲区提取产品;互斥:生产者向缓冲区输送产品时,禁止消费者进入,同理,消费者从缓冲区取走产品时,禁止生产者输送产品。信号量:一组整型变量,为控制临界资源而产生的一个或一组计数器;P操作申请资源,信号值减1;V操作释         放资源,信号量加1信号量控制:semctl(semid, semnu,

2013-03-18 17:46:42 401

原创 消息队列

消息队列:先进先出根据不同的交易类型组建不同的消息报文,填写不同的消息类型,写入同一消息队列。各类交易处理程序分别从消息队列中读取特定类型的消息并处理(即使不在队头,读完后从队列中删除)发送端:#include #include #include using namespace std;extern int errno;struct Msg{lo

2013-03-18 17:45:21 408

原创 报文解析

操作文件:c++ 标准文件编程库、低级文件编程库报文解析读取passwd中的用户名#include #include using namespace std;int main(){     int fd1 = open("/etc/passwd", O_RDONLY);     if(fd1      {coutreturn -1;

2013-03-15 20:05:21 1166

原创 unix精确定时

#include #include #include using namespace std;int n=0;void timefunc(int sig){signal(SIGPROF, timeunc);cout}int main(){struct itimerval value;value.it_value.tv_sec=1;

2013-03-15 20:03:58 385

原创 I/O操作

操作设备文件操作连接到主机串口的外设(密码键盘)打开串口设备:int open(char* devname){int fd;if((fd = open(devname, O_RDWR)) {coutreturn -1;}if((ioctl(fd, TCGETA, &oldtty)) {coutclose(fd);reteurn -

2013-03-15 20:03:05 462

原创 记录锁

#include #include using namespace std;int main(int argc, char* argv[]){int fd = open("a.txt", O_RDWR|O_CREAT, 0777);if(fd{coutreturn -1;}struct flock arg;arg.l_type = F_RDL

2013-03-15 20:01:58 507

原创 unix网络编程之udp

#include    #include    #include    using namespace std;   int main(int argc, char* argv[])   {short port = 12345;if(argc > 1)  port = atoi(argv[1]); int ss = socket(AF_INET,SO

2013-03-08 21:12:52 348

原创 unix网络编程之tcp

ipserver.cc:  #include   #include   #include   using namespace std;  int main(int argc, char* argv[])  {int ss = socket(AF_INET, SOCK_STREAM, 0);if(ss {   cout   return -1;

2013-03-08 21:11:42 284

原创 消息队列

消息队列,写进程#include #include using namespace std;int main(int argc, char* argv[]){    if(argc == 1)    {coutreturn 0;    }    int key = atoi(argv[1]);    int qid = msgget(

2013-03-07 21:12:27 388

原创 管道

单向无名管道:占用两个文件描述符(读,写),用于父子进程中父写子读#include using namespace std;int main(){int fileds[2];char buf[256];pid_t pid;if(pipe(fileds) {coutexit(-1);}if((pid=fork())

2013-03-07 21:11:06 453

原创 unix 信号

中断信号,自定义信号    #include     #include     using namespace std;    void func(int sig)    {if(sig == SIGINT)   coutelse   if(sig == SIGUSR1)       cout   else       if(sig == S

2013-03-07 21:09:16 353

原创 进程

退出处理函数class A{    public: A(){   cout}~A(){   cout}};void f(){  cout        }A gobj;int main(){  A obj;  atexit(f);  cout  exit(0);  cout}

2013-03-06 18:04:20 368

原创 获取系统信息

取得计算机名      #include       using namespace std;      int main()      {  char name[256]={};  int res;  res = gethostname(name, 256);  if(res cout  elsecout      }

2013-03-06 18:01:24 514

原创 文件操作

获取文件描述信息     #include      #include      using namespace std;     int main(int argc, char* argv[])     {  char* name = NULL;  name = argv[1]// 命令行传递文件名  struct stat s;  stat(

2013-03-06 17:59:55 320

原创 unix下目录操作

目录操作:    查看当前工作目录:     #include      using namespace std;     int main()     {  char buf[256] = {};  size_t size;  getcwd(buf, size);  cout     }     查看当前目录下的文件     #in

2013-03-04 19:42:59 295

原创 读取用户信息

获取用户信息 #include  using namespace std; int main() {      cout      cout } 获取用户信息函数 #include  #include  using namespace std; int main(int argc, char* argv[])//命令行参数传递

2013-03-04 19:41:28 348

原创 获取unix环境变量

声明:unix板块下代码参考《21天学通c++》、精通UNIX下c语言编程与项目实践获取所有环境变量内容  #include   using namespace std;  int main(int argc, char* argv[], char* env[])  {for(int i=0; env[i]!=NULL; ++i)//编程习惯:对于指针数组,如果不说

2013-03-04 19:37:55 271

原创 静态顺序表的实现

/*******************************************the headfile of static sequence list, which defines the class of static seqlistfilename: sta_seqlist.hcopyright: cozzwauthor: zzwcreated date: 201

2013-01-31 10:25:11 205

转载 利用栈将中缀表达式转换成后缀表达式

目的:将中缀表达式(即标准形式的表达式)转换为后缀式。例子:a+b*c+(d*e+f)*g转换成abc*+de*f+g*+ 转换原则:1.当读到一个操作数时,立即将它放到输出中。操作符则不立即输出,放入栈中。遇到左圆括号也推入栈中。2.如果遇到一个右括号,那么就将栈元素弹出,将符号写出直到遇到一个对应的左括号。但是这个左括号只被弹出,并不输出。3.在读到操作符时,如

2012-10-11 17:18:01 871 1

原创 大白菜傻瓜式u盘装机

第一步:制作u盘启动盘                 1、下载大白菜u盘启动盘制作工具                 2、安装此工具                 3、打开这个自作工具,选择要制作的u盘,然后单击一键制成usb启动盘                 4、下载系统镜像文件到该启动盘                 至此,启动盘制作成功!第二步:设置bio

2012-10-08 15:37:10 1534

原创 String 类构造函数

String::String(const char *str){      if(NULL==str)      {            m_data = new char[1];            if(m_data==NULL)             {                 cout                 break;

2012-10-03 07:07:26 654

原创 函数返回值系列之一返回指针类型的局部变量

char *  getString(void) {         char   p[] = "hello world";         return p;}//p 中保存的是栈中内容hello  world 的首地址,而随着函数调用的结束hello world 被清除,所以p中保存的是乱码,函数的返回值正是指向该乱码的指针void test4(v

2012-09-23 19:14:50 261

unix程序员手册

该资源为unix程序员必备的手册,内容清楚,完整

2013-01-10

makefile文件的编写

本文章详细介绍了make工具的使用以及makefile文件的编写方法和技巧

2013-01-01

数据结构和算法面试题

微软数据结构与算法,看到该文件的网友有福了,哈哈!

2012-12-27

c、c++面试题

c程序员面试必读资料,学习c的必备资料,它可以助你早日找到工作,更深入了解c

2012-12-27

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除