07 2021 档案

摘要:#include <unistd.h> #include <signal.h> #include <string.h> #include <sys/wait.h> #include <stdio.h> #define MAXLINE 100 static void sig_int(int); int 阅读全文
posted @ 2021-07-22 13:20 东宫得臣 阅读(56) 评论(0) 推荐(0) 编辑
摘要:对每个文件维护3个时间字段, st_atime 文件数据的最后访问时间(read) st_mtime 文件数据的最后修改时间(write) st_ctime i节点状态的最后更改时间(chmod、chown) 修改时间是文件内容最后一次被修改的时间,状态更改时间是该文件的i节点最后一次被修改的时间。 阅读全文
posted @ 2021-07-22 09:48 东宫得臣 阅读(70) 评论(0) 推荐(0) 编辑
摘要:一个简单的ls命令的实现: #include <stdio.h> #include <stdlib.h> #include <dirent.h> int main(int argc, char *argv[]) { DIR *dp; struct dirent *dirp; if(argc != 2 阅读全文
posted @ 2021-07-21 18:05 东宫得臣 阅读(71) 评论(0) 推荐(0) 编辑
摘要:Bounded data(有界的数据) A type of dataset that is finite in size. Unbounded data(无界的数据) A type of dataset that is infinite in size. Streaming system A typ 阅读全文
posted @ 2021-07-20 17:28 东宫得臣 阅读(105) 评论(0) 推荐(0) 编辑
摘要:服务器程序 #include <stdio.h> #include <sys/un.h> #include <sys/socket.h> #include <errno.h> #include <unistd.h> #define SV_SOCK_PATH "/tmp/us_xfr" #define 阅读全文
posted @ 2021-07-20 15:06 东宫得臣 阅读(239) 评论(0) 推荐(0) 编辑
摘要:函数体与函数调用相联系称为捆绑。晚捆绑又称为动态捆绑或运行时捆绑。为了引起晚捆绑,c++要求在基类中声明这个函数时使用virtual关键字。 不把析构函数设为虚函数是一个隐匿的错误,因为它常常不会对程序有直接的影响。但会不知不觉地引入存储器泄露。 #include <iostream> #inclu 阅读全文
posted @ 2021-07-15 10:55 东宫得臣 阅读(78) 评论(0) 推荐(0) 编辑
摘要:线程的主要优势在于,能够通过全局变量来共享信息。必须确保多个线程不会同时修改同一变量,或者某一线程不会读取正由 其他线程修改的变量。临界区是指访问某一共享资源的代码片段,并且这段代码的执行应为原子操作,亦即,同时访问同一共享 资源的其他线程不应中断该片段的执行。可以使用互斥量来保证对任意共享资源的原 阅读全文
posted @ 2021-07-15 09:26 东宫得臣 阅读(37) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> #include <sys/resource.h> int main() { struct rlimit rlim; if(getrlimit(RLIMIT_MEMLOCK, &rlim) == -1) { fprintf(stderr, "getrlimit 阅读全文
posted @ 2021-07-14 17:17 东宫得臣 阅读(181) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> #include <sys/mman.h> #include <sys/stat.h> #include <fcntl.h> #include <string.h> #include <unistd.h> int main(int argc, char *arg 阅读全文
posted @ 2021-07-14 15:43 东宫得臣 阅读(133) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> #include <sys/wait.h> #include <unistd.h> #include <string.h> #define BUF_SIZE 10 int main(int argc, char *argv[]) { int pfd[2]; ch 阅读全文
posted @ 2021-07-14 12:08 东宫得臣 阅读(53) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> #include <stdlib.h> static void atexitFunc1(void) { printf("atexit function 1 called.\n"); } static void atexitFunc2(void) { printf 阅读全文
posted @ 2021-07-14 09:04 东宫得臣 阅读(54) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> #include <unistd.h> static int idata = 111; int main() { int istack = 222; pid_t childPid; switch(childPid = fork()) { case -1: fpr 阅读全文
posted @ 2021-07-14 08:44 东宫得臣 阅读(130) 评论(0) 推荐(0) 编辑
摘要:发现一篇文章,讲解这两个之间的区别,很详细。 find -exec vs find | xargs (everythingcli.org) 阅读全文
posted @ 2021-07-12 14:31 东宫得臣 阅读(39) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <sstream> #include <algorithm> #include <iterator> #include <cmath> template<class T> struct chainNode{ T element; chainN 阅读全文
posted @ 2021-07-08 13:09 东宫得臣 阅读(46) 评论(0) 推荐(0) 编辑
摘要:uname()系统调用返回了一系列关于主机系统的标识信息。 #include <sys/utsname.h> int uname(struct utsname *utsbuf); Returns 0 on success, or -1 on error #define _UTSNAME_LENGTH 阅读全文
posted @ 2021-07-06 13:34 东宫得臣 阅读(406) 评论(0) 推荐(0) 编辑
摘要:#include <unistd.h> #include <stdio.h> int main() { enum {PATHMAX = 256}; char buf[PATHMAX]; int val; char *cwd; cwd = getcwd(buf, PATHMAX); /*remembe 阅读全文
posted @ 2021-07-05 11:14 东宫得臣 阅读(139) 评论(0) 推荐(0) 编辑
摘要:package mypackage import ( "encoding/json" "fmt" "io/ioutil" "log" "os" "database/sql" _ "github.com/lib/pq" ) func LoadConfig(path string) Config { j 阅读全文
posted @ 2021-07-05 09:25 东宫得臣 阅读(1069) 评论(0) 推荐(0) 编辑
摘要:package main import ( "encoding/json" "fmt" "io/ioutil" "os" "strconv" "time" ) type ResponseStruct struct { Signs []Sign `json:"signs"` } type Sign s 阅读全文
posted @ 2021-07-05 09:04 东宫得臣 阅读(207) 评论(0) 推荐(0) 编辑
摘要:void f(vector<string>& v, int i, const char *p) { if(p == nullptr) return; if(i<0 || v.size()<=i) error("bad index."); string s = v[i]; if(s == p) { / 阅读全文
posted @ 2021-07-04 21:31 东宫得臣 阅读(71) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> int main() { int v[] = {1, 2, 3, 4, 5}; for(auto& x:v) std::cout<<x<<" "; std::cout<<std::endl; return 0;} We use auto where we do 阅读全文
posted @ 2021-07-04 17:44 东宫得臣 阅读(139) 评论(0) 推荐(0) 编辑
摘要:用函数原型,在声明和定义一个函数时,必须使用参数类型描述。这种描述就是“原型”。 调用函数时,编译器使用原型确保正确传递参数并且正确地处理返回值。如果调用函数时程序 员出错了,编译器就会捕获这个错误。在函数原型中,参数表包含了应当传递给函数的参数类型 和参数的标识符(对声明而言可以是任选的)。参数的 阅读全文
posted @ 2021-07-04 15:53 东宫得臣 阅读(547) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示