Linux系统编程 进度%60
This commit is contained in:
parent
378fec8ac9
commit
6de2de0331
BIN
Linux系统编程篇/02目录IO/mkdir
Executable file
BIN
Linux系统编程篇/02目录IO/mkdir
Executable file
Binary file not shown.
22
Linux系统编程篇/02目录IO/mkdir.c
Normal file
22
Linux系统编程篇/02目录IO/mkdir.c
Normal file
@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
if(argc !=2 )
|
||||
{
|
||||
printf("uage:%s <name file\n",argv[0]);
|
||||
return -1;
|
||||
}
|
||||
ret = mkdir(argv[1],0666);
|
||||
if(ret<0)
|
||||
{
|
||||
printf("mkdir is error\n");
|
||||
}
|
||||
|
||||
printf("mkdir is ok\n");
|
||||
return 0;
|
||||
}
|
BIN
Linux系统编程篇/02目录IO/openAndCloseDir
Executable file
BIN
Linux系统编程篇/02目录IO/openAndCloseDir
Executable file
Binary file not shown.
25
Linux系统编程篇/02目录IO/openAndCloseDir.c
Normal file
25
Linux系统编程篇/02目录IO/openAndCloseDir.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
DIR *dp;
|
||||
if (argc !=2){
|
||||
printf("Usage:%s <name file>\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
dp = opendir(argv[1]);
|
||||
if (dp !=NULL){
|
||||
printf("opendir is ok\n");
|
||||
return -1;
|
||||
}
|
||||
closedir(dp);
|
||||
printf("opendir is closed\n");
|
||||
return 0;
|
||||
}
|
BIN
Linux系统编程篇/02目录IO/readdir
Executable file
BIN
Linux系统编程篇/02目录IO/readdir
Executable file
Binary file not shown.
32
Linux系统编程篇/02目录IO/readdir.c
Normal file
32
Linux系统编程篇/02目录IO/readdir.c
Normal file
@ -0,0 +1,32 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{ int ret;
|
||||
DIR *dp;
|
||||
struct dirent *dir;
|
||||
if (argc != 2){
|
||||
printf("Uage:%s <name file>\n",argv[0]);
|
||||
return -1;
|
||||
};
|
||||
dp = opendir(argv[1]);
|
||||
if (dp == NULL) {
|
||||
printf("opendir is error\n\n");
|
||||
return -2;
|
||||
}
|
||||
printf("opendir is ok\n");
|
||||
while(1)
|
||||
{
|
||||
dir = readdir(dp);
|
||||
if (dir!=NULL) {
|
||||
printf("file name is %s\n",dir->d_name);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
closedir(dp);
|
||||
return 0;
|
||||
}
|
0
Linux系统编程篇/02目录IO/test/a.test
Normal file
0
Linux系统编程篇/02目录IO/test/a.test
Normal file
BIN
Linux系统编程篇/03库的制作与使用/动态库制作/a.out
Executable file
BIN
Linux系统编程篇/03库的制作与使用/动态库制作/a.out
Executable file
Binary file not shown.
BIN
Linux系统编程篇/03库的制作与使用/动态库制作/libmylib.so
Executable file
BIN
Linux系统编程篇/03库的制作与使用/动态库制作/libmylib.so
Executable file
Binary file not shown.
6
Linux系统编程篇/03库的制作与使用/动态库制作/mylib.c
Normal file
6
Linux系统编程篇/03库的制作与使用/动态库制作/mylib.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include <stdio.h>
|
||||
void mylib(void);
|
||||
void mylib(void)
|
||||
{
|
||||
printf("This is mylib\n");
|
||||
}
|
BIN
Linux系统编程篇/03库的制作与使用/动态库制作/mylib.o
Normal file
BIN
Linux系统编程篇/03库的制作与使用/动态库制作/mylib.o
Normal file
Binary file not shown.
7
Linux系统编程篇/03库的制作与使用/动态库制作/test.c
Normal file
7
Linux系统编程篇/03库的制作与使用/动态库制作/test.c
Normal file
@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void mylib(void);
|
||||
int main(void){
|
||||
mylib();
|
||||
return 0;
|
||||
}
|
BIN
Linux系统编程篇/03库的制作与使用/静态库制作/a.out
Executable file
BIN
Linux系统编程篇/03库的制作与使用/静态库制作/a.out
Executable file
Binary file not shown.
BIN
Linux系统编程篇/03库的制作与使用/静态库制作/libmylib.a
Normal file
BIN
Linux系统编程篇/03库的制作与使用/静态库制作/libmylib.a
Normal file
Binary file not shown.
6
Linux系统编程篇/03库的制作与使用/静态库制作/mylib.c
Normal file
6
Linux系统编程篇/03库的制作与使用/静态库制作/mylib.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include <stdio.h>
|
||||
void mylib(void);
|
||||
void mylib(void)
|
||||
{
|
||||
printf("This is mylib\n");
|
||||
}
|
BIN
Linux系统编程篇/03库的制作与使用/静态库制作/mylib.o
Normal file
BIN
Linux系统编程篇/03库的制作与使用/静态库制作/mylib.o
Normal file
Binary file not shown.
7
Linux系统编程篇/03库的制作与使用/静态库制作/test.c
Normal file
7
Linux系统编程篇/03库的制作与使用/静态库制作/test.c
Normal file
@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void mylib(void);
|
||||
int main(void){
|
||||
mylib();
|
||||
return 0;
|
||||
}
|
BIN
Linux系统编程篇/04进程基础/a.out
Executable file
BIN
Linux系统编程篇/04进程基础/a.out
Executable file
Binary file not shown.
23
Linux系统编程篇/04进程基础/getpid.c
Normal file
23
Linux系统编程篇/04进程基础/getpid.c
Normal file
@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
pid_t pid;
|
||||
pid = fork();
|
||||
if (pid < 0)
|
||||
{
|
||||
printf("fork is error\n");
|
||||
return -1;
|
||||
}
|
||||
// 父进程
|
||||
if (pid > 0) {
|
||||
printf("This is parent, parent pid is %d\n",getppid());
|
||||
}
|
||||
// 子进程
|
||||
if (pid == 0){
|
||||
printf("This is child, child pid is %d\n",getpid());
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user