File Compressor in C
- 7 Devlogs
- 14 Total hours
Writing C file compressor! After cs50x (where my favorite language was C) i wanted to get back at the level i had before since i didnt code in C for 5 sections of the course.
Writing C file compressor! After cs50x (where my favorite language was C) i wanted to get back at the level i had before since i didnt code in C for 5 sections of the course.
its a real question why only I ? I used f it was so cool.
Use other letters for your loops. I’m onto something guys, it’s the next big thing.
P.S: I’m going to take a break from coding in C since its pretty anoying and im not really doing anything while working maybe this challenge is really too hard for me.
I’m maybe going to start another project then see.
I’m super tired and my brain cells aren’t working right.
sticker by fancy void
Finnaly finished compressor.c after 7 hours on it!
Well i used AI… Yes I’m not proud but hey its finished!
I was really tired and I just vibe coded it but now no more AI for decompressor.c !
Yes i didn’t blindly ask AI do give answers i asked to help debug the code!
Probably sleep, I’m so tired.
Finally finished coding everything but the tree.
so for relearning, i authorized myself to use AI but only to debug, now i can finally not use it (since i relearned C)
I ran into several problems:
For context i was building the compressor and i had segmentation problems
A segmentation problem is when you try and access memory your don’t have access.
I used AI to debug my code, I didnt directly asked for the awnsers, i asked it to help me without giving out awnsers. AI was very useful since i mad alot of small mistakes since i didnt program in C for a long time.
Redid one exercise from CS50x Psets 2, 3, 4, and 5.
I wanted to refresh my C programming skills because after Week 5 the course shifts more toward web applications, databases, and other topics. This was a good way to get back into writing C before continuing work on Stardance.
Huffman Coding is a lossless compression algorithm.
Example text: ffffcdabdfdeeebcc
First, count how often each character appears:
f:4 c:3 d:3 e:3 b:2 a:1
Then repeatedly merge the least frequent characters into a binary tree until one final tree remains.
Each character gets a binary code:
0
1
More frequent characters receive shorter codes, reducing the total file size.
A key rule: no code can start with another code.
If f = 1, then 100 cannot be another character, so decoding stays unambiguous.
Time complexity: O(n log n)
Image: GeeksforGeeks
Video: Computerphile – Huffman Coding