+ 1

I was working on little excersize project and I found interesting problem. How would you solve it?

Last week I was practising on my c language skills. I was trying to write a simple program that would be able to open text file and find one choosen word. I know there is many functions with similar effects but I wanted to make that one from scratch. Then I realised many "troublesome treats". The most intriguing: Before I inserted searched word I had to declare char array big enough to provide space for long words. There was a lot of wasted space in case of short word however I could not declare array without precising its size. What would you do in my shoes? Could dynamic arrays help hereor maybe there is any obvious trick that I've missed? Thx for advices.

6th Apr 2020, 12:48 AM
Daniel Brodowski
Daniel Brodowski - avatar
2 odpowiedzi
+ 6
interesting)) ... try writing a multi-map with a variable string length key and a value being a pointer to the record structure stored in a dynamic array. This is a very interesting challenge. Requires skills to design a tree - for example, binary, or better red-black. Skills in implementing functions that mimic OOP classes like in C ++. Skills of working with dynamic arrays. C is a cool language - anything is possible. But the truth is through their work. 🤘😎
28th Sep 2020, 6:52 PM
Michail Getmanskiy
Michail Getmanskiy - avatar
+ 3
Maybe you can use the <Arraylist> like in java
6th Apr 2020, 8:35 PM
Abhiraj Ghumare
Abhiraj Ghumare - avatar