How to reduce a bigger string in smaller string in C++? Probably by hashing?

前端 未结 3 1838
广开言路
广开言路 2021-01-16 15:13

I want to compress a bigger string into a smaller string in C++. What are the different ways to do this in C++? The requirement is that output should also be a string.

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-16 15:55

    Well, if you don't need to uncompress it later:

    string s = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
    s = "";
    

    Edit: Sounds like you want a hash function - there are a zillion out there, depending on your requirements. Google is your friend.

提交回复
热议问题