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 8748635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:33:37+00:00 2026-06-13T12:33:37+00:00

This may or may not be a very simple question, but I would like

  • 0

This may or may not be a very simple question, but I would like to know what function to call in order to figure out how many bytes are in an array at any given time. For example, how would I know what to put as the third argument in the send command in the code below?

int *array= new int[500];
memset(array, 0, sizeof(array));

//newsockfd is declared elsewhere in the code
send(newsockfd, array, _______, 0);
  • 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-06-13T12:33:38+00:00Added an answer on June 13, 2026 at 12:33 pm

    The size of an array is constant (it’s just a hunk of memory).

    You’ll need to keep track of how many elements of the array are valid yourself, in a separate variable.

    As others have noted, the last argument to memset should be the number of bytes you want set to 0 — but array is just a pointer, so sizeof(array) will yield only 4 (or 8 on a 64-bit platform). Again, you’ll need to manually pass in sizeof(int) * 500 (or use a constant for the 500 so you don’t have to update the number in multiple places if it changes).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may not be a programming question, but I don't know where to ask
This may be a very simple question, but at the moment I don't actually
I think this may be a very simple question, but I am only just
This may turn out to be a simple question with a very complex answer,
This may or may not be a very trivial question, but then again, I'm
I think this has to be a very simple question but I am not
So this may be a very simple question that I'm overthinking but if I
This may not be the kind of question one should ask on StackOverflow, but
Sorry, this may or may not be a programming question directly, but I am
This may seem a basic question but my is not currently working. I am

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.