随笔分类 - C/C++
摘要:#include <stdlib.h> #include <string.h> #include <unistd.h> #include <errno.h> #include <pthread.h> void sys_err(const char *str) { perror(str); exit(
阅读全文
摘要:【说明】 在父进程中使用wait。流程如下: 父进程没有子进程,调用wait后,不阻塞父进程,父进程按照正常流程执行。 父进程有子进程,但是所有子进程的状态都不是“挂起”状态,把父进程设置成“等待”状态。 父进程有子进程,而且这个子进程的状态是“挂起”状态,回收子进程占用的进程表,并且解除父进程的阻
阅读全文
摘要:#include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(void) { int fd; //创建文件,获取文件描述符 fd = open("ps.out",O_WRONLY|O_CR
阅读全文
摘要:函数说明: execlp()会从PATH 环境变量所指的目录中查找符合参数file的文件名,找到后便执行该文件,然后将第二个以后的参数当做该文件的argv[0]、argv[1]……,最后一个参数必须用空指针(NULL)作结束。如果用常数0来表示一个空指针,则必须将它强制转换为一个字符指针,否则将它解
阅读全文
摘要:#include <unistd.h> #include <sys/types.h> #include <stdio.h> int main(void) { int fd[2]; int pid; if(pipe(fd) == -1) perror("pipe");//创建子进程 pid = for
阅读全文
摘要:#include <stdio.h> typedef struct { int val;//指向下一个节点 struct node *p_next; }node; int main(){ node node1 = {10}, node2 = {20},node3 = {30}; node head
阅读全文
摘要:1,窗口设计 为了便于代码部分阅读,现将窗口各部分objectName名称展示如下 1.1 服务器端窗口设计 [1],listWidget [2], portEdit [3],createButton 1.2 客户端窗口设计 [1], listWidget [2], messageEdit [3],
阅读全文
摘要:#include <iostream> using namespace std; struct job { char name[40]; double salary; int floor; }; void show(job &j); template <typename T> void Swap(T
阅读全文
摘要:server.cpp客户端代码实现 1 #include "server.h" 2 #include "ui_server.h" 3 4 server::server(QWidget *parent) : 5 QWidget(parent), 6 ui(new Ui::server) 7 { 8 u
阅读全文
摘要:1 #include <iostream> 2 3 using namespace std; 4 5 struct free_throws 6 { 7 string name; 8 int made; 9 int attempts; 10 float percent; 11 }; 12 13 voi
阅读全文
摘要:#include <iostream> using namespace std; void swapr(int &a,int &b); void swapp(int *pa,int *pb); void swapv(int a,int b); int main() { int wallet1=300
阅读全文
摘要:void Widget::paintEvent(QPaintEvent *) { //创建画家类对象 QPainter p(this); //创建新画笔 QPen pen; pen.setColor(/*Qt::green*/QColor(0,255,0)); pen.setWidth(10); p
阅读全文
摘要:1 #include <stdio.h> 2 #include <string.h> 3 #define SIZE 81 4 #define LIM 3 5 #define HALT "" 6 void stsrt(char *string[],int num); 7 char *s_gets(ch
阅读全文
摘要:void fit(char *string,unsigned int size){ if(strlen(string) > size) string[size]='\0';}
阅读全文
摘要:代码实现 1 #include "timerun.h" 2 #include "ui_timerun.h" 3 4 timerun::timerun(QWidget *parent) : 5 QMainWindow(parent), 6 ui(new Ui::timerun), 7 mtime(0,
阅读全文
摘要:1,显示效果 2,页面布局 显示控件选择LCD Numer digitCount默认为5,不够用调整为10 3,具体代码 1 #include "timeshow.h" 2 #include "ui_timeshow.h" 3 4 timeshow::timeshow(QWidget *parent
阅读全文
摘要:1,显示效果 2,页面编辑方式,画好页面之后转到槽函数 3,各个槽函数代码简单实现 3.1,打开 1 void Filewin::on_actionopen_triggered() 2 { 3 QString fitler=QString("Text from(*.cpp *.h)"); 4 fil
阅读全文
摘要://单击按钮显示目录下所有文件槽函数 void filewindow::on_pushButton_clicked() { //获取对话框路径 QString dirpath=QFileDialog::getExistingDirectory(this,"choose directory","./"
阅读全文
摘要:主要为了配合学习QT,还有一些bug,先不深究 #include "calc.h" #include "ui_calc.h" calc::calc(QWidget *parent) : QMainWindow(parent), ui(new Ui::calc) { ui->setupUi(this)
阅读全文
摘要:#include "layout.h" #include "ui_layout.h" Layout::Layout(QWidget *parent) : QMainWindow(parent), ui(new Ui::Layout) { ui->setupUi(this); window_init(
阅读全文