Question
I need to write a simple program called kv in C language. It is a simple persistent key-value store. The program will have a few
I need to write a simple program called "kv" in C language. It is a simple persistent key-value store.
The program will have a few options. The first is to insert some (key, value) pairs into the database. This is accomplished as follows:
```sh
prompt> ./kv
prompt> ./kv p,10,remzi
prompt> ./kv p,20,andrea p,40,someotherperson
```
```sh
prompt> ./kv g,10
10,remzi
prompt>
```
There are many many ways to implement such a feature. Here, we suggest something very simple. The idea will be to use a single file (called, say, `database.txt`), where you store all of this information in plain-text format.
```sh
prompt> cat database.txt
1,first
2,second
prompt>
```
CFLAGS=-O2 -Wall -Werror
This is Makefile
kv: kv.c
$(CC) -o kv $< $(CFLAGS)
test: kv
bash test-kv.sh
clean:
rm -f database.txt kv
rm -fr tests-out
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started