CSE 2011 Midterm Exam --v1.0.pdf

CSE 2011 Midterm Exam --v1.0.pdf

ID:34406705

大小:455.28 KB

页数:12页

时间:2019-03-05

CSE 2011 Midterm Exam --v1.0.pdf_第1页
CSE 2011 Midterm Exam --v1.0.pdf_第2页
CSE 2011 Midterm Exam --v1.0.pdf_第3页
CSE 2011 Midterm Exam --v1.0.pdf_第4页
CSE 2011 Midterm Exam --v1.0.pdf_第5页
资源描述:

《CSE 2011 Midterm Exam --v1.0.pdf》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库

1、ComputerSystemEngineeringSpring2011MidtermExaminationProblem(1:(Naming(Scheme((8’)(!In!“bbs.fudan.edu.cn”,!when!an!article!is!posted,!it!would!be!stored!as!a!file!with!a!filename!by!prefix!and!timestamp,!rather!than!the!title!of!article,!as!following:!!/*

2、*##*#Creates#a#new#file#in#specific#location.##*#@param[in]#dir#The#directory.##*#@param[in]#pfx#Prefix#of#the#file.##*#@param[in,#out]#fname#The#resulting#filename.##*#@param[size]#The#size#of#fname.##*#@return#Filename#and#stream#on#success,#NULL#on#err

3、or.##*#@see#::date_to_fname.##*/#static#FILE#*get_fname(const#char#*dir,#const#char#*pfx,#################char#*fname,#size_t#size)#{#########const#char#c[]#=#"ZYXWVUTSRQPONMLKJIHGFEDCBA";#########int#t#=#(int)time(NULL);#########int#count#=#snprintf(fnam

4、e,#size,#"%s%s%d.#",#dir,#pfx,#t);##########int#fd;#########for#(int#i#=#sizeof(c)#a#1;#i#>=#0;#iaa)#{#################fname[count#a#1]#=#c[i];#################if#((fd#=#open(fname,#O_CREAT#

5、#O_WRONLY#

6、#O_EXCL,#0644))#>#0)#{#########################FILE#*

7、fp#=#fdopen(fd,#"w");#########################if#(fp)#{#################################return#fp;#########################}#else#{#################################close(fd);#################################return#NULL;#########################}##########

8、#######}#########}#########return#NULL;#}#*!snprintf()!does!not!write!more!than!size!bytes!(including!the!trailing!'').!!Which(of(the(followings(are(true?((8’)((A.The!file!system!of!BBS!only!supports!a!limited!length!of!filename.!If!the!title!of!the!art

9、icle!exceeds!the!maximum!length!of!filename,!it!must!be!cut!off.!B.The!filename!is!generated!in!the!form!of!timestamp,!in!order!to!accelerate!the!discovery!and!read!procedures.!C.Many!articles!in!one!board!would!probably!have!similar,!or!even!the!same!tit

10、le.!So!using!timestamp!to!generate!a!unique!filename!could!mostly!avoid!the!problem.!D.The!filenames!are!generated!using!timestamps,!so!that!they!could!be!sorted!naturally,!and!thus!it!is!much!convenient!for!search!

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。