Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
214 views
in Technique[技术] by (71.8m points)

How to check if a byte from a byte array contains 0 using C?

I have a byte array of strings. How can I check if a byte in that array contains 0? For example:

char byte_arr[5] = "abc00";

The last two bytes of the above array contains 0. How can I detect that in c?

question from:https://stackoverflow.com/questions/65917020/how-to-check-if-a-byte-from-a-byte-array-contains-0-using-c

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Simple algorithm to follow

count_zero = 0
for each element a, in byte_array
    check if a is '0'
        count_zero++  

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...