Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7428679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:50:28+00:00 2026-05-29T08:50:28+00:00

I have a buffer of size 1500. In that buffer I need to check

  • 0

I have a buffer of size 1500. In that buffer I need to check whether 15 bytes are all zeros or not (from 100 to 115). How can we do this (if we do not use any loop for it)? Data is of type “unsigned char”, actually it is an unsigned char array.

Platform : Linux, C, gcc compiler

Will using memcmp() be correct or not? I am reading some data from a smart card and storing them in a buffer. Now I need to check whether the last 15 bytes are consecutively zeros or not.
I mentioned memcmp() here because I need an efficient approach; already the smart card reading has taken some time.

Or going for bitwise comparison will be correct or not . Please suggest .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:50:29+00:00Added an answer on May 29, 2026 at 8:50 am
    unsigned char buffer[1500];
    ...
    bool allZeros = true;
    for (int i = 99; i < 115; ++i)
    {
        if (buffer[i] != 0)
        {
            allZeros = false;
            break;
        }
    }
    

    .

    static const unsigned char zeros[15] = {0};
    ...
    unsigned char buffer[1500];
    ...
    bool allZeros = (memcmp(&buffer[99], zeros, 15) == 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have found that the default video buffer size was set to 8 seconds
I have this code that writes successfully a file: ofstream outfile (path); outfile.write(buffer,size); outfile.flush();
Hi I have the following program to check the send buffer size for a
I understand that certain data type object have certain buffer size. E.g. a char
I have set the buffer to size 100. I display the buffer in the
I have a buffer in class 'bufferClass' that will generate a signal to tell
I have a memory buffer corresponding to my screen resolution (1280x800 at 24-bits-per-pixel) that
I have a raw buffer with it i need to make 3 others, the
i have a char buffer[100] and i'm trying to use gdb to read the
I have a direct buffer holding Integers that are already sorted (i.e. 1,1,3,3,3,3,7,7,....). Most

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.