大文件 [英] Large Files
问题描述
嗨朋友们,
在一次采访中我被要求写一个C程序来创建一个大文件
8GB
第一个4GB填充Hello
和secod 4GB填充World
很抱歉,我不知道如何以优雅的方式做到这一点。我认为
这是一个技巧问题,取决于size_t是32位还是64位。
有人知道吗?
>
感谢您的回答!
raj写道:
朋友们,
在一次采访中,我被要求编写一个C程序来创建一个大文件
8GB
第一个4GB填充Hello
和secod 4GB填充World
很抱歉,我不知道如何以优雅的方式做到这一点。我认为
这是一个技巧问题,取决于size_t是32位还是64位。
有人知道怎么做?
转到groups.google.com并在comp.lang.c中搜索包含大
个文件的邮件在名字里。最近一次发生的是2007-11-08。
" raj" < ra*@spamtrap.invalidwrote in message
朋友们,
在一次采访中我被要求写一个C程序创建一个大文件
8GB
第一个4GB填充Hello
和secod 4GB充满了世界
很抱歉,我不知道如何以优雅的方式做到这一点。我认为
这是一个技巧问题,取决于size_t是32位还是64位。
有人知道吗?
>
感谢您的回答!
长期将为您提供2G的空间。因为你只需要4/5 G就可以获得
" Hello"另外4/5为世界你只是在极限范围内。
每次调用fprintf / fwrite后检查ferror是明智的,
因为文件系统不可能不能支持如此大的
文件,否则会耗尽空间。然而它只是一个普通的C函数
通话工作,如果要求写1K
或者每个都没有什么不同。
这是一个跨平台问题。特定的架构可能有不好的标准库,需要对大文件进行特殊调用。你不能合理地预计会知道所有这些细节,尽管提问者
可能没有意识到 - 在这种情况下它是棘手的社交但不是技术>
情况。
-
免费游戏和编程好东西。
http://www.personal.leeds.ac.uk/~bgy1mm
Malcolm McLean写道:
" raj" < ra*@spamtrap.invalidwrote in message
>嗨朋友们,
在一次采访中我被要求写一个C程序创建一个8GB的大文件
第一个4GB充满了Hello
而secod 4GB充满了World
/>
很抱歉,我不知道如何以优雅的方式做到这一点。我认为
这是一个技巧问题,取决于size_t是32位还是64位。
有人知道吗?
感谢您的回答!
长会给你2G的空间。
说谁?
-
Ian Collins。
Hi friends,
In an interview I was asked to write a C program to create a large file
of 8GB
The first 4GB is filled with "Hello"
and the secod 4GB is filled with "World"
Sorry to say that I don''t know how to do that in an elegant way. I think
it is a trick question depending on if size_t is 32 bits or 64 bits.
Does anybody know how?
Thanks for answering!
raj wrote:Hi friends,
In an interview I was asked to write a C program to create a large file
of 8GB
The first 4GB is filled with "Hello"
and the secod 4GB is filled with "World"
Sorry to say that I don''t know how to do that in an elegant way. I think
it is a trick question depending on if size_t is 32 bits or 64 bits.
Does anybody know how?Go to groups.google.com and search comp.lang.c for messages with "large
files" in the name. The most recent occurrence was 2007-11-08.
"raj" <ra*@spamtrap.invalidwrote in messageHi friends,
In an interview I was asked to write a C program to create a large file
of 8GB
The first 4GB is filled with "Hello"
and the secod 4GB is filled with "World"
Sorry to say that I don''t know how to do that in an elegant way. I think
it is a trick question depending on if size_t is 32 bits or 64 bits.
Does anybody know how?
Thanks for answering!
A long will give you 2G of space. Since you only need 4/5 G for the for the
"Hello" and another 4/5 for the "World" you are just within limits.
It would be prudent to check ferror after each call to fprintf / fwrite,
since it is not unlikely that the filesystem cannot support such large
files, or will run out of space. However it is just an ordinary C function
call job, not different in any way from if the requirement was to write 1K
or each.
That assumes a cross-platform question. Particular architecures may have
poor standard libraries that require special calls for large files. You
can''t reasonably be expected to know all these details, though questioner
might not realise that - in which case it is tricky social but not technical
situation.
--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm
Malcolm McLean wrote:"raj" <ra*@spamtrap.invalidwrote in message>Hi friends,
In an interview I was asked to write a C program to create a large file
of 8GB
The first 4GB is filled with "Hello"
and the secod 4GB is filled with "World"
Sorry to say that I don''t know how to do that in an elegant way. I think
it is a trick question depending on if size_t is 32 bits or 64 bits.
Does anybody know how?
Thanks for answering!
A long will give you 2G of space.
Says who?
--
Ian Collins.
这篇关于大文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!