构建 zip 压缩器/解压缩器以提高 C 技能
我想提高我的 C 技能,并一直在考虑尝试编写自己的 zip 和解压缩程序。这似乎涉及很多领域,CPU/HDD/内存。
我从哪里开始?是否有压缩和解压缩操作的流程图?对于这种类型的项目来说是不是太复杂了?
一本介绍所有步骤的好书还是一个网站?
我想知道是否有人对此有任何好的资源或者可能有任何其他建议。
I want to refine my C skills and have been thinking of trying to write my own zip and unzip program. This seems hit on a lot of areas, CPU/HDD/Memory.
Where do I start? Is there a flow chart of what to do to compress and uncompress? Is it too complicated for this type of project?
A good book that steps through all the steps to take or a site?
I wonder if anyone has any good resources for this or maybe any additional suggestions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可能想阅读维基百科上的 Huffman 编码。编码非常简单,您可以通过它实现一定程度的压缩。这种压缩算法将帮助您处理链表、内存分配-释放以及正确选择数据结构。
如果你想实现一些非常简单的东西,只需实现运行长度编码即可。
You might want to read up on Huffman encoding on wikipedia. The encoding is pretty simple, and you can achieve some level of compression with this. This compression algorithm will help you with linked lists, memory allocation-deallocation, and correct choice of data structures.
If you want to implement something extremely simple, just implement Run Length Encoding.
我首先仔细查看以下维基百科页面的外部链接(它们链接到格式的完整规范):
I'd start by having a good look at the external links at the following wikipedia pages (they link to full specifications of the format):
附加建议,以防万一您正在寻找更困难的东西。
该程序 Crinkler 专门用于压缩小型可执行文件。以下是关于其工作原理的信息。
Additional suggestion, just in case you are looking for something more difficult.
The program Crinkler specializes in compressing small executables. Here is info about how it works.
ZIP 是两种东西的组合:文件打包格式和(一组)压缩算法。第一个有点平淡,但会磨练你的小技巧,第二个更有趣、更先进。
我记得必须用 C 语言实现 LZW 编码和解码才能读取和写入 GIF 文件。这将是一个很好的项目,因为 LZW 压缩非常非常聪明 - 这是我见过的唯一值得申请专利的算法之一,并且是比 ZIP 更容易实现的目标
ZIP is a combination of 2 things, a file packaging format and a (set of) compression algorithms. The first is a bit prosaic but would hone your bit-didling skills, the second more interesting and advanced.
I remember having to implement LZW encoding and decoding in C in order to read and write GIF files. This would be a fine project, as LZW compression is very very clever - one of the only algorithms I've seen that I think deserves a patent, and a much more achievable aim than ZIP
您可能想看看 Zip、Gzip、Bzip 和 7-Zip 等开源应用程序,它们在整个压缩文件方面实现了自己的变体。 7-Zip 特别有自己的压缩格式 (7z),实际上,它生成的文件比使用直接 zip 时要小,因此有一些东西需要学习。
我并不是说复制他们的代码或任何东西,但看看别人以前做过的事情通常可以让你开始转动,让你以不同的方式思考问题,这将帮助你获得一些前进的动力。
You might want to take a look at open source applications like Zip, Gzip, Bzip, and 7-Zip, which implement their own variations on the whole compress files thing. 7-Zip specifically has their own compression format (7z) that actually gets files smaller than if you were to use straight zip, so there's something to be learned there.
I'm not saying copy their code or anything but looking at something someone has done before can usually get the wheels turning and get you to think about the problem in a different way that will help you get some forward momentum.