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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:24:41+00:00 2026-06-01T17:24:41+00:00

my problem is that having this code: int size=4384; char buffer[size]; codifyDHCPmessage(buffer, message, size);

  • 0

my problem is that having this code:

int size=4384;
char buffer[size];
codifyDHCPmessage(buffer, message, size);

where message is an struct which only contains char[], and the function return in buffer, all the fields from the struct.

I test it going through the buffer array, and checking that all the fields are ok.

But my problem is that if i pass again that buffer into a new function as:

decodifyDHCPmessage(buffer,messageAux, size);

the first thing I do in that function is to check the size of buffer, which only tells me that is 4, when it’s suppossed to be 4384…. and I don’t know why.

I have to tell that I’m not an expert in C, and the pointer, and memory allocation issues are hard for me.

Thanks a lot in advance.

  • 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-01T17:24:43+00:00Added an answer on June 1, 2026 at 5:24 pm

    I suspect that your function signature looks like this:

    void codifyDHCPmessage(char[], message_t, size_t);
    

    (or similar)

    The problem is that [] in a function signature really means *, that is, char[] is really char*. In other words, the array argument decays to a pointer whose size is, unsurprisingly, 4.

    As far as I know (but I could be wrong …), C doesn’t allow you to pass arrays into functions at all, it just supports pointers. That’s why you need to pass the size as an explicit separate argument.

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

Sidebar

Related Questions

This is a really weird problem that I have been having. When I download
I'm trying to create this effect: http://www.thecssninja.com/demo/css_tree/ the problem I'm having is that the
I'm having a problem with this query that takes several seconds to complete. I
I am having a problem like this one: http://svn.haxx.se/tsvnusers/archive-2008-07/1051.shtml Except that the app is
I'm having a problem. I have a UIView, that looks like this : In
I am having this problem in below code as my ArrayList both name and
I am having a problem when I create an array of strings, this only
I am having some problems figuring out this issue. I have a server that
I'm having the weird problem that after having javascript inject some dom-elements the css-rules
The problem that I am having has to do with the need to keep

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.