国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

IO進(jìn)程線程day3(2023.7.31)

這篇具有很好參考價(jià)值的文章主要介紹了IO進(jìn)程線程day3(2023.7.31)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

一、Xmind整理:

IO進(jìn)程線程day3(2023.7.31),算法

文件描述符概念:

IO進(jìn)程線程day3(2023.7.31),算法

二、課上練習(xí):

練習(xí)1:用fread和fwrite實(shí)現(xiàn)文件拷貝?

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <head.h>
int main(int argc, const char *argv[])
{
	//以讀的方式打開源文件
	FILE* fp_r=fopen("./01_fopen.c","r");
	if(NULL==fp_r)
	{
		ERR_MSG("fopen");
		return -1;
	}
    //以寫的方式打開源文件
	FILE* fp_w=fopen("./copy.c","w");
	if(NULL==fp_w)
	{
		ERR_MSG("fopen");
		return -1;
	}

	//讀一次寫一次,直到文件讀取完畢
	char buf[128]="";
	size_t res=0;
	while(1)
	{
		bzero(buf,sizeof(buf));
		//以128為單位,讀取1個(gè)數(shù)據(jù),所當(dāng)不足128的時(shí)候
		//剩下的數(shù)據(jù)讀取不出來(lái),所以這個(gè)代碼是錯(cuò)誤的
		res=fread(buf,1,sizeof(buf),fp_r);
		printf("res=%ld\n",res);
		if(0==res)
			break;
		fwrite(buf,1,res,fp_w);
	}
	printf("拷貝完畢\n");

	//關(guān)閉
	fclose(fp_w);
	fclose(fp_r);


	return 0;
}

IO進(jìn)程線程day3(2023.7.31),算法

練習(xí)2:time

功能:從1970-1-1日至今的秒數(shù)
原型:
 #include <time.h>
 time_t time(time_t *tloc);
參數(shù):
time_t *tloc:若不為空,則1970-1-1日至今的秒數(shù)同樣會(huì)被存儲(chǔ)到該指針指向的內(nèi)存空間中;
返回值:
成功,返回1970-1-1日至今的秒數(shù);
失敗,返回((time_t) -1),更新errno;
time_t t = time(NULL);  
printf("%ld\n", t);
time_t pt;                     
time(&pt);
printf("%ld\n", pt);

練習(xí)3:localtime

功能:將1970-1-1日至今的秒數(shù)轉(zhuǎn)換成日歷格式
原型:
#include <time.h>
struct tm *localtime(const time_t *timep);
參數(shù):
time_t *timep: 指定要轉(zhuǎn)換成日歷格式的秒數(shù)的首地址;
返回值:
成功,返回結(jié)構(gòu)體指針;  vi -t tm可以查看struct tm 成員 或者man手冊(cè)往下翻
失敗,返回NULL;更新errno;      
struct tm {
             int tm_sec;    /* Seconds (0-60) */         秒
             int tm_min;    /* Minutes (0-59) */         分
             int tm_hour;   /* Hours (0-23) */           時(shí)
             int tm_mday;   /* Day of the month (1-31) */  日
             int tm_mon;    /* Month (0-11) */             月= tm_mon+1
             int tm_year;   /* Year - 1900 */              年= tm_year+1900
             int tm_wday;   /* Day of the week (0-6, Sunday = 0) */    星期
             int tm_yday;   /* Day in the year (0-365, 1 Jan = 0) */   一年中的第幾天

          };
例題:?
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <head.h>
int main(int argc, const char *argv[])
{
	/*
	time_t t=time(NULL);
	printf("%ld\n",t);

	time _t pt;
	time(&pt);
	printf("%d\n",pt);
	*/
	time_t t;
	struct tm* info=NULL;

	while(1)
	{
		t=time(NULL);
		info=localtime(&t);
		printf("%d-%02d-%02d %02d:%02d:%02d\r",\
				info->tm_year+1900,info->tm_mon+1,info->tm_mday,\
				info->tm_hour,info->tm_min,info->tm_sec);
		fflush(stdout);
		sleep(1);
	}

	return 0;
}

IO進(jìn)程線程day3(2023.7.31),算法

練習(xí)4:文件描述符的總量

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <head.h>
int main(int argc, const char *argv[])
{
	printf("%d %d %d\n",stdin->_fileno,stdout->_fileno,stderr->_fileno);
	FILE*fp=NULL;
	while(1)
	{
		fp=fopen("./1.txt","w");
		if(NULL==fp)
		{
			ERR_MSG("fopen");
			return -1;
		}
		printf("%d ",fp->_fileno);
		fflush(stdout);
	}
	return 0;
}

IO進(jìn)程線程day3(2023.7.31),算法

IO進(jìn)程線程day3(2023.7.31),算法

練習(xí)5:open

功能:打開一個(gè)文件
原型:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int open(const char *pathname, int flags);
int open(const char *pathname, int flags, mode_t mode);
參數(shù):
 char *pathname:指定要打開的文件的路徑和名字;
 int flags:打開方式
     O_RDONLY     只讀, 
     O_WRONLY     只寫,
     O_RDWR       讀寫
 ----以上三種必須包含一種----------
     O_APPEND     追加方式打開,
     O_TRUNC      清空,若文件存在,且是一個(gè)普通文件,且以寫的方式打開
     O_CREAT      若文件不存在,則創(chuàng)建一個(gè)普通文件。
 若有多個(gè)選項(xiàng)合成一個(gè)打開方式,則用按位或連接:
     "w":O_WRONLY | O_CREAT | O_TRUNC
 mode_t mode:用來(lái)指定文件創(chuàng)建的時(shí)候的權(quán)限,例如:0664
 若flags中包含了O_CREAT或者O_TMPFILE的時(shí)候,就必須寫mode參數(shù);
 若flags沒有O_CREAT或者O_TMPFILE的時(shí)候,會(huì)忽略mode參數(shù);
返回值:
成功,返回文件描述符,
失敗,返回-1,更新errno;
注意:

標(biāo)準(zhǔn)IO中的 r r+ w w+ a a+,用文件IO中的flags進(jìn)行組合。

IO進(jìn)程線程day3(2023.7.31),算法?

練習(xí)6:umask

the mode of the created file is (mode & ~umask).

文件創(chuàng)建時(shí)候的真實(shí)權(quán)限是 mode & ~umask

mode: 0777 -> 111 111 111 umask?111 111 101=> ~umask -> umask = 000 000 010 = 0002

結(jié)果: 0775 ----> 111 111 101

i. umask是什么

文件權(quán)限掩碼,目的就是影響文件創(chuàng)建時(shí)候的權(quán)限。可以通過(guò)設(shè)置umask的值保證某些用戶肯定沒有某些權(quán)限。

ii. 獲取umask的值

終端輸入:umask

iii. 修改umask的值

1.終端輸入: umask 0 只在設(shè)置終端有效

2.umask()函數(shù)

 #include <sys/types.h>
 #include <sys/stat.h>
 mode_t umask(mode_t mask);
 umask(0);

練習(xí)7:close

功能:關(guān)閉文件; 釋放文件描述符
原型:
#include <unistd.h>
int close(int fd);
參數(shù):
int fd:指定要關(guān)閉的文件描述符;
返回值:
成功,返回0;
失敗,返回-1,更新errno;

練習(xí)8:write

功能:將數(shù)據(jù)寫入到文件中
原型:
 #include <unistd.h>
 ssize_t write(int fd, const void *buf, size_t count);
參數(shù):
int fd:指定要將數(shù)據(jù)寫入到哪個(gè)文件中,填對(duì)應(yīng)的文件描述符;
void *buf:指定要輸出的數(shù)據(jù)的首地址,可以是任意類型數(shù)據(jù);
size_t count:指定要輸出的數(shù)據(jù)字節(jié)數(shù);
返回值:
成功,返回成功輸出的字節(jié)數(shù);
失敗,返回-1,更新errno;
?例題:?創(chuàng)建一個(gè)權(quán)限是0777的文件,并在數(shù)據(jù)寫入到文件中
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <head.h>
int main(int argc, const char *argv[])
{
	//將本程序的umask的值修改成0
	umask(0);
	int fd=open("./open.txt",O_WRONLY|O_CREAT|O_TRUNC,0777);
	if(fd<0)
	{
		ERR_MSG("open");
		return -1;
	}
	printf("open success\n");

	ssize_t res=0;
	char buf[]="hello world";
	res=write(fd,buf,sizeof(buf));
	printf("res=%ld\n",res);

	if(close(fd)<0)
	{
		ERR_MSG("close");
		return -1;
	}
	printf("close success\n");
	return 0;
}

IO進(jìn)程線程day3(2023.7.31),算法

注意:?

write函數(shù)指定寫多少個(gè)字節(jié),就會(huì)從內(nèi)存中拿多少個(gè)字節(jié),寫入到文件中,即使越界

練習(xí)9:read

功能:從文件中讀取數(shù)據(jù)
原型:
#include <unistd.h>
ssize_t read(int fd, void *buf, size_t count);
參數(shù):
int fd:指定要從哪個(gè)文件中讀取數(shù)據(jù),填對(duì)應(yīng)的文件描述符;
void *buf:指定要將讀取到的數(shù)據(jù)存儲(chǔ)到那塊空間中,可以是任意類型數(shù)據(jù);
size_t count:指定要讀取的數(shù)據(jù)字節(jié)數(shù);
返回值:
 >0, 成功,返回成功讀取的字節(jié)數(shù);
 =0, 文件讀取完畢;
 =-1, 失敗,返回-1,更新errno;
?例題1:?read的使用
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <head.h>
int main(int argc, const char *argv[])
{
	//將本程序的umask的值修改成0
	umask(0);
	int fd=open("./01_fileno.c",O_RDONLY);
	if(fd<0)
	{
		ERR_MSG("open");
		return -1;
	}
	printf("open success\n");

	ssize_t res=0;
	char buf[128]="";

	while(1)
	{
		bzero(buf,sizeof(buf));
		res=read(fd,buf,sizeof(buf));
		if(0==res)
		{
			break;
		}
		//將數(shù)據(jù)寫到終端,寫的個(gè)數(shù)為實(shí)際讀取到的字節(jié)數(shù)
		write(1,buf,res);
	}

#if 0
	while(1)
	{
		bzero(buf,sizeof(buf));
		/***************************************/
		//由于后續(xù)打印的是使用%s打印,所以需要保留一個(gè)\0位置
		//防止%s打印的時(shí)候越界少\0位 
		res=read(fd,buf,sizeof(buf)-1);
		if(0==res)
		{
			break;
		}
		printf("%s",buf);    //%s打印直到遇到\0位置
	}
#endif
	printf("讀取完畢\n");
	if(close(fd)<0)
	{
		ERR_MSG("close");
		return -1;
	}
	printf("close success\n");

	return 0;
}

IO進(jìn)程線程day3(2023.7.31),算法

?例題2:用read和write函數(shù)實(shí)現(xiàn),拷貝圖片

?提示:1.ls-l查看圖片類型

? ? ? ? ? ? 2.eog? 圖片--->打開圖片

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <head.h>
int main(int argc, const char *argv[])
{
	//以讀的方式打開源文件
	int fd_r=open("./1.png",O_RDONLY);
	if(fd_r<0)
	{
		ERR_MSG("open");
		return -1;
	}
	printf("open success\n");
	//以寫的方式打開目標(biāo)文件
	int fd_w=open("./2.png",O_WRONLY|O_CREAT|O_TRUNC,0664);
	if(fd_w<0)
	{
		ERR_MSG("open");
		return -1;
	}

	ssize_t res=0;
	char buf[128]="";
	//讀一次寫一次
	while(1)
	{
		bzero(buf,sizeof(buf));
		res=read(fd_r,buf,sizeof(buf));
		if(0==res)
		{
			break;
		}
		//讀多少個(gè)就寫多少個(gè)
		if(write(fd_w,buf,res)<0)
		{
			ERR_MSG("write");
			return -1;
		}
	}
	printf("拷貝完成\n");
	//關(guān)閉
	if(close(fd_r)<0)
	{
		ERR_MSG("close");
		return -1;
	}
	if(close(fd_w)<0)
	{
		ERR_MSG("close");
		return -1;
	}

	printf("close success\n");
	return 0;
}

IO進(jìn)程線程day3(2023.7.31),算法

練習(xí)10:lseek

功能:修改文件偏移量
原型:
#include <sys/types.h>
#include <unistd.h>
off_t lseek(int fd, off_t offset, int whence);
參數(shù):
int fd:文件描述符;
off_t offset: 距離whence參數(shù)指定的偏移量。往前偏移填負(fù)數(shù), 往后偏移填正數(shù)
int whence:
    SEEK_SET,  文件開頭位置
    SEEK_CUR,  文件當(dāng)前位置
    SEEK_END   文件結(jié)尾位置
返回值:
成功,修改偏移量后,文件當(dāng)前位置距離文件開頭的偏移量;
失敗,返回-1,更新errno;    
//計(jì)算文件大小
off_t size = lseek(fd_r, 0, SEEK_END);
printf("size=%ld\n", size);
例題:lseek的使用?
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <head.h>
int main(int argc, const char *argv[])
{
	//以讀的方式打開源文件
	int fd_r=open("./1.png",O_RDONLY);
	if(fd_r<0)
	{
		ERR_MSG("open");
		return -1;
	}
	//計(jì)算文件大小
	off_t size=lseek(fd_r,0,SEEK_END);
	printf("size=%ld\n",size);
	//關(guān)閉
	close(fd_r);
	return 0;
}

IO進(jìn)程線程day3(2023.7.31),算法

注意:?

若偏移量在文件開頭,能否繼續(xù)往前偏移 --->?不行

若偏移量在文件結(jié)尾,能否繼續(xù)往后偏移 ---> 可以

練習(xí)11:獲取文件屬性

IO進(jìn)程線程day3(2023.7.31),算法

練習(xí)12:stat

功能:獲取文件的屬性
原型:
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
 int stat(const char *pathname, struct stat *statbuf);
參數(shù):
char *pathname:指定要獲取屬性的文件路徑以及名字;
struct stat *statbuf:存儲(chǔ)獲取到的屬性;
返回值:
成功,返回0;
失敗,返回-1,更新errno;
    
vi -t stat 或者 man手冊(cè)往下翻
struct stat 
{
 ino_t     st_ino;         /* Inode number */            inode號(hào)
 mode_t    st_mode;        /* File type and mode */      文件類型和權(quán)限
 nlink_t   st_nlink;       /* Number of hard links */    硬鏈接數(shù)
 uid_t     st_uid;         /* User ID of owner */        用戶的uid
 gid_t     st_gid;         /* Group ID of owner */       組用戶的gid
 off_t     st_size;        /* Total size, in bytes */    文件大小

 struct timespec st_atim;  /* Time of last access */         最后一次被訪問(wèn)的時(shí)間
 struct timespec st_mtim;  /* Time of last modification */   最后一次被修改的時(shí)間
 struct timespec st_ctim;  /* Time of last status change */  最后一次改變狀態(tài)的時(shí)間
 #define st_atime st_atim.tv_sec      /* Backward compatibility */
 #define st_mtime st_mtim.tv_sec
 #define st_ctime st_ctim.tv_sec
};
提取文件的權(quán)限:

mode_t st_mode 本質(zhì)上是一個(gè)unsigned int類型,里面存儲(chǔ)了文件的類型和權(quán)限。

st_mode中其中低9bits存儲(chǔ)了文件的權(quán)限:[0bit - 8bit]

IO進(jìn)程線程day3(2023.7.31),算法

例題:文件權(quán)限提取?
#include <stdio.h>
#include <head.h>

void get_filePermission(mode_t m)   //mode_t m = buf.st_mode
{
    if((m & 0400) != 0)
        putchar('r');
    else
        putchar('-');

    if((m & 0200) != 0)                                      
        putchar('w');
    else
        putchar('-');

    if((m & 0100) != 0)
        putchar('x');
    else
        putchar('-');

    ///
    if((m & 0040) != 0)
        putchar('r');
    else
        putchar('-');

    if((m & 0020) != 0)
        putchar('w');
    else
        putchar('-');

    if((m & 0010) != 0)
        putchar('x');
    else
        putchar('-');
    

    if((m & 0004) != 0)
        putchar('r');
    else
        putchar('-');

    if((m & 0002) != 0)
        putchar('w');
    else
        putchar('-');

    if((m & 0001) != 0)
        putchar('x');
    else
        putchar('-');

    return;
}
int main(int argc, const char *argv[])
{
    struct stat buf;
    if(stat("./01_fileno.c", &buf) < 0)
    {
        ERR_MSG("stat");
        return -1;
    }

    //文件的類型和權(quán)限
    printf("mode: 0%o\n", buf.st_mode);
    get_filePermission(buf.st_mode);

    //文件的硬鏈接數(shù)
    printf("link: %ld\n", buf.st_nlink);

    //文件的所屬用戶
    printf("uid: %d\n", buf.st_uid);

    //文件所屬組用戶
    printf("gid: %d\n", buf.st_gid);

    //文件大小
    printf("size: %ld\n", buf.st_size);

    //文件的修改時(shí)間
    printf("time: %ld\n", buf.st_ctime);

    //文件的名字
	
    return 0;
}

IO進(jìn)程線程day3(2023.7.31),算法

三、課后作業(yè):

1.用read函數(shù)計(jì)算文件的大小?

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <head.h>
int main(int argc, const char *argv[])
{
	int fd = open("./1.png",O_RDONLY);
	if(fd < 0)
	{
		ERR_MSG("open");
		return -1;
	}
	printf("open success\n");

	off_t size = lseek(fd,0,SEEK_END);
	printf("size=%ld\n",size);

	char c;
	ssize_t res = 0;
	int count = 0;
	lseek(fd,0,SEEK_SET);
	while(1)
	{
		res = read(fd,&c,1);
		if(0 == res)
			break;
		count++;
	}
	printf("count=%d\n",count);

	if(close(fd) < 0)
	{
		ERR_MSG("close");
		return -1;
	}
	printf("close success\n");

	return 0;
}

IO進(jìn)程線程day3(2023.7.31),算法

2.將課上的文件權(quán)限提取修改成循環(huán)方式

#include <stdio.h>
#include <head.h>

void get_filePermission(mode_t m)
{
	long x=0400;
	char c[]="rwx";
	int count=0;
	while(x)
	{
		if((m & x) != 0)
			putchar('r');
		else
			putchar('-');
		x=x>>1;
		if((m & x) != 0)                                      
			putchar('w');
		else
			putchar('-');
		x=x>>1;
		if((m & x) != 0)
			putchar('x');
		else
			putchar('-');
		x=x>>1;
	}

	return;
}
int main(int argc, const char *argv[])
{
    struct stat buf;
    if(stat("./01_fileno.c", &buf) < 0)
    {
        ERR_MSG("stat");
        return -1;
    }

    //文件的類型和權(quán)限
    printf("mode: 0%o\n", buf.st_mode);
    get_filePermission(buf.st_mode);

    //文件的硬鏈接數(shù)
    printf("link: %ld\n", buf.st_nlink);

    //文件的所屬用戶
    printf("uid: %d\n", buf.st_uid);

    //文件所屬組用戶
    printf("gid: %d\n", buf.st_gid);

    //文件大小
    printf("size: %ld\n", buf.st_size);

    //文件的修改時(shí)間
    printf("time: %ld\n", buf.st_ctime);
	
    return 0;
}

IO進(jìn)程線程day3(2023.7.31),算法文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-621278.html

到了這里,關(guān)于IO進(jìn)程線程day3(2023.7.31)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 【趣學(xué)算法】Day3 貪心算法——背包問(wèn)題

    【趣學(xué)算法】Day3 貪心算法——背包問(wèn)題

    14天閱讀挑戰(zhàn)賽 努力是為了不平庸~ 算法學(xué)習(xí)有些時(shí)候是枯燥的,這一次,讓我們先人一步,趣學(xué)算法! ???一名熱愛Java的大一學(xué)生,希望與各位大佬共同學(xué)習(xí)進(jìn)步?? ??個(gè)人主頁(yè):@周小末天天開心 各位大佬的點(diǎn)贊?? 收藏? 關(guān)注?,是本人學(xué)習(xí)的最大動(dòng)力 感謝! ??該

    2024年02月02日
    瀏覽(17)
  • IO 與進(jìn)程線程

    2023年05月28日
    瀏覽(24)
  • 深度學(xué)習(xí)DAY3:神經(jīng)網(wǎng)絡(luò)訓(xùn)練常見算法概述

    這是最常見的神經(jīng)網(wǎng)絡(luò)訓(xùn)練方法之一。它通過(guò)計(jì)算損失函數(shù)對(duì)權(quán)重的梯度,并沿著梯度的反方向更新權(quán)重,從而逐步減小損失函數(shù)的值。梯度下降有多個(gè)變種,包括隨機(jī)梯度下降(SGD)和小批量梯度下降。 反向傳播是一種基于鏈?zhǔn)椒▌t的方法,用于計(jì)算神經(jīng)網(wǎng)絡(luò)中每個(gè)神經(jīng)元

    2024年02月07日
    瀏覽(24)
  • IO進(jìn)程線程,文件IO(open),文件(stat)與目錄(opendir)屬性的讀取

    IO進(jìn)程線程,文件IO(open),文件(stat)與目錄(opendir)屬性的讀取

    ? ? ? 一、文件IO 1、文件io通過(guò)系統(tǒng)調(diào)用來(lái)操作文件 系統(tǒng)調(diào)用:系統(tǒng)提供給用戶的一組API(接口函數(shù)) ??????? open/read/write/close/lseek... 用戶空間進(jìn)程訪問(wèn)內(nèi)核的接口 把用戶從底層的硬件編程中解放出來(lái) 極大的提高了系統(tǒng)的安全性 使用戶程序具有可移植性(同一系統(tǒng)下) 是操作

    2024年02月11日
    瀏覽(30)
  • Day31- 貪心算法part05

    題目一:453. 無(wú)重疊區(qū)間? 435. 無(wú)重疊區(qū)間 給定一個(gè)區(qū)間的集合? intervals ?,其中? intervals[i] = [starti, endi] ?。返回? 需要移除區(qū)間的最小數(shù)量,使剩余區(qū)間互不重疊? 。 主要思想是優(yōu)先保留結(jié)束時(shí)間早的區(qū)間,這樣留給其他區(qū)間的空間就更多,從而減少需要移除的區(qū)間數(shù)量

    2024年01月19日
    瀏覽(26)
  • 【算法日志】貪心算法刷題:重疊區(qū)問(wèn)題(day31)

    【算法日志】貪心算法刷題:重疊區(qū)問(wèn)題(day31)

    目錄 前言 無(wú)重疊區(qū)間(篩選區(qū)間) 劃分字母區(qū)間(切割區(qū)間) ?合并區(qū)間 今日的重點(diǎn)是掌握重疊區(qū)問(wèn)題。

    2024年02月12日
    瀏覽(27)
  • IO進(jìn)程線程第五天(8.2)進(jìn)程函數(shù)+XMind(守護(hù)進(jìn)程(幽靈進(jìn)程),輸出一個(gè)時(shí)鐘,終端輸入quit時(shí)退出時(shí)鐘)

    IO進(jìn)程線程第五天(8.2)進(jìn)程函數(shù)+XMind(守護(hù)進(jìn)程(幽靈進(jìn)程),輸出一個(gè)時(shí)鐘,終端輸入quit時(shí)退出時(shí)鐘)

    1.守護(hù)進(jìn)程(幽靈進(jìn)程) 2.輸出一個(gè)時(shí)鐘,終端輸入quit時(shí)退出時(shí)鐘 ? ? ? ?

    2024年02月14日
    瀏覽(20)
  • 代碼隨想錄day31 貪心算法初探

    ????????就像卡哥視頻里說(shuō)的一樣,感覺貪心算法確實(shí)沒什么固定的套路,唯一的思路就是求局部最優(yōu)解然后推廣到全局最優(yōu)解,但是什么是局部最優(yōu)解,這個(gè)需要慢慢做題來(lái)摸索總結(jié),有點(diǎn)像調(diào)參,蠻玄學(xué)的,純考腦子 假設(shè)你是一位很棒的家長(zhǎng),想要給你的孩子們一些

    2024年01月18日
    瀏覽(994)
  • Day 31 C++ STL常用算法(下)

    copy——容器內(nèi)指定范圍的元素拷貝到另一容器中 函數(shù)原型 copy(iterator beg, iterator end, iterator dest); // 按值查找元素,找到返回指定位置迭代器,找不到返回結(jié)束迭代器位置 // beg 開始迭代器 // end 結(jié)束迭代器 // dest 目標(biāo)起始迭代器 注意——利用copy算法在拷貝時(shí),目標(biāo)容器要提前

    2024年02月12日
    瀏覽(42)
  • IO進(jìn)程線程,文件與目錄,實(shí)現(xiàn)linux任意目錄下ls -la

    注意文件的名字、路徑是如何輸入的。 函數(shù)opendir打開目錄,struct dirent,struct stat這些結(jié)構(gòu)體的含義。? ????????readdir()函數(shù)是一個(gè)用于讀取目錄內(nèi)容的系統(tǒng)調(diào)用或庫(kù)函數(shù),在類Unix操作系統(tǒng)中(如Linux)廣泛使用。它用于遍歷目錄,并逐個(gè)獲取目錄中的條目(文件和子目錄

    2024年02月10日
    瀏覽(23)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包