Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- { 0x7f, 0x10, 0x7f, 0x7f, 0x10, 0x7f, 0x7f, 0x7f, 0x7f, 0x11, 0x7f, 0x7f };
- { 0x7f, 0x10, 0x7f, 0x10, 0x7f, 0x7f, 0x11, 0x7f };
- const unsigned char _ssp_stx = 0x7f;
- //--------------------------------------------------------------------------
- void stx_shrink(std::vector<char>& data)
- {
- std::vector<char> result;
- result.reserve(data.size());
- bool stx_lock { false };
- for (int i = 0; i < data.size(); ++i)
- {
- if (stx_lock == true)
- {
- stx_lock = false;
- if ((unsigned char)data[i] == _ssp_stx)
- continue;
- }
- if ((unsigned char)data[i] == _ssp_stx)
- stx_lock = true;
- result.push_back(data[i]);
- }
- data = result;
- }
- int main()
- {
- std::vector<char> test = { 0x7f, 0x10, 0x7f, 0x7f, 0x10, 0x7f, 0x7f, 0x7f, 0x7f, 0x11, 0x7f, 0x7f };
- stx_shrink(test);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement