store known key/value pairs in c

后端 未结 4 410
孤独总比滥情好
孤独总比滥情好 2020-12-30 05:21

I\'m currently learning c. I\'m writing a web server as an exercise.
Now i have to store the status codes and reason phrases.

What is the best way to store those

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-30 05:42

    Maybe you can create a struct with the K\V in it.

    Like so:

    struct key_value
    {
       int key;
       char* value;
    };
    
    struct key_value kv;
    
    kv.key = 1;
    kv.value = "foo";
    

提交回复
热议问题