Let's say I have a unsigned char
buffer that looks like this:
unsigned char buffer = {'A', 'B', 'C', 'A', 'B', 'C', 'A', 'B', 'C', 'A', 'B', 'C'}
Basically I just want to grab that A's and B's, and pack them into a new buffer like this:
unsigned char buffer2 = {'A', 'B', 'A', 'B', 'A', 'B' ... etc
is there an efficient way to do this besides looping through every single element? Is there some trick you can do with memcpy
or memset
?
Thanks!