摘要:
alarm(设置信号传送闹钟) 相关函数 signal,sleep表头文件 #include<unistd.h>定义函数 unsigned int alarm(unsigned int seconds);函数说明 alarm()用来设置信号SIGALRM在经过参数seconds指定的秒数后传送给目前的进程。如果参数seconds 为0,则之前设置的闹钟会被取消,并将剩下的时间返回。返回值返回之前闹钟的剩余秒数,如果之前未设闹钟则返回0。范例 #include<unistd.h> #include<signal.h> void handler() { prin 阅读全文
摘要:
#include <sys/types.h> /* 提供类型pid_t的定义 */ #include <sys/wait.h> pid_t wait(int *status) 进程一旦调用了wait,就立即阻塞自己,由wait自动分析是否当前进程的某个子进程已经退出,如果让它找到了这样一个已经变成僵尸的子进程,wait就会收集这个子进程的信息,并把它彻底销毁后返回;如果没有找到这样一个子进程,wait就会一直阻塞在这里,直到有一个出现为止,当然 如果在调用wait()时子进程已经结束,则wait()就会立即返回子进程... 阅读全文
摘要:
引用与所代表的变量 共占一段内存 引用不占用内存 因此调用时非常快速并节省空间声明引用必须初始化(除作为参数和返回值)int &b=a;声明引用后,不可再被当做其他变量的引用int a1,a2;int &b1 = a1;b1 = a2; //ERROR指针变量也是变量 因此有指针变量的引用没有void 引用,引用的引用,指向引用的指针、引用数组、空引用需要指出的是 常量不能被引用 const int to int& is errorconst int to int const & is right指针的引用类型 *&指针引用名 = 指针;int n = 阅读全文
摘要:
#include <iostream>using namespace std;template <class T> class B { public: void show(T a); };template <class T> void B<T>::show(T a) { cout<<a<<endl; }template <class T1,class T2> class A:public B<T2> { public: void Test(T1 a,T2 b); };template <cla 阅读全文
摘要:
public.h#ifndef _PUBLIC_H_#define _PUBLIC_H_#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/types.h>#include <unistd.h>#include <sys/stat.h>#include <sys/ipc.h>#include <sys/msg.h>#include <time.h>#include <strings.h># 阅读全文
摘要:
下面的数据声明都代表什么?float(**def)[10]def是一个二级指针,他指向的是一个一维数组的指针,数组的元素都是floatdouble*(*gh)[10]gh是一个指针,他指向一个一维数组,数组元素都是double *double(*f[10])();f是一个数组,f有10个元素,元素都是函数的指针,指向的函数类型是没有参数且返回double的函数int*((*b)[10]);就跟"int *(*b)[10]"是一样的,是一维数组的指针Long (* fun)(int)函数指针int (*(*F)(int,int))(int)F是一个函数的指针,指向的是函数的类 阅读全文
摘要:
写出函数指针、函数返回指针、const指针、指向const的指针、指向const的const指针答案:void (f*)()void * f()const int*int* constconst int* const函数指针的使用#include<stdio.h>//这里最好可以使用<cstdio.h>int max(int x,int y){ return x>y?x:y;}int main(){ int max(int,int);//这两行代码通常是是关于函数指针调用的,通常用做考点 int (*p)(int,int)=&max; int a,b,c, 阅读全文
摘要:
在linux中安装安装sendmail直接yum-yinstallsendmail然后yum-yinstallsendmail-cf 阅读全文
摘要:
消息队列 A 和 B 是 相对独立的两支程序,现在 A 传送 10 个Student 到 B B 将Student 读取出来,显示在界面上 然后 B 传送 10 个 Teacher 到 A ,A 显示 teacher 在界面上#include "public.h"typedef struct students{long mtype;int no;char username[100];}*StusNode,SNode;int main(){int ret=-1;int msg_flags,msg_id;key_t key;struct msqid_ds msg_info;SN 阅读全文
摘要:
IPC 有命管道 创建一个有名管道 /tmp/stduent.data A 和 B 是 相对独立的两支程序,现在 A 传送 10 个Student 到 B B 将Student 读取出来,显示在界面上 然后 B 传送 10 个 Teacher 到 A ,A 显示 teacher 在界面上A.cpp#include "public.h"#define FIFO_NAME "/temp/Linux/my_fifo"#define BUFFER_SIZE PIPE_BUF#define TEN_MEG (1024*1024*10)typedef struct 阅读全文