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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:26:24+00:00 2026-06-18T15:26:24+00:00

I have a function: int somefunction(int a, int b, char *c, int d){} Now

  • 0

I have a function:

int somefunction(int a, int b, char *c, int d){}

Now this function is called in an other function which is in main().

I call somefunction(a, b, c, d); and I have it print out int a, witch is declared as 50, before somefunction() is called. In the first call 50 is printed, all good and dandy, but the second call of somefunction() prints out 29549.
These function calls are inside some if statements, and even if the second place were somefunction() is called, is called first it’s the same.

For testing all the input values have been set as the same, so its not the input.
All in put values is printed before calling somefunction(), and are as they should be. I have tried renaming all variables, functions, I tried to change all int’s to float, and I tried moving the order of the variables in somefunction(). But noting changed. I have made prototypes as well, it’s not that.

So does anyone have any idea of what could course this? The actual code is not here because I passed 2000 lines, and there would be a lot of irrelevant code in between. I realize it might be hard to help me, so I am only asking if anyone have experienced anything similar.

  • 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-18T15:26:25+00:00Added an answer on June 18, 2026 at 3:26 pm

    So, if I’m using a language with pointers and unsafe arrays, and crazy things start happening, then I have to soon suspect that I’m overwriting memory. There are many ways to do this: writing past the end of an array, using an uninitialized pointer, free()ing something that was never malloc()ed, etc.

    If that’s what’s happening in your case, it’s very hard to solve it without seeing the precise and complete code (trying to make a simplified example will often just make the problem go away as you either remove the erroneous code or rearrange memory so that something different and perhaps innocuous is being overwritten).

    If you can’t post a complete example that exhibits the bug, then you can start looking at likely culprits: a) all use of dynamic memory functions, b) all dereferencing of pointers.

    About all I could glean from your other post was a) yup, that’s the kind of code that’s ripe for wild pointers and b) hmmmm, what’s this:

    char char_buffer[] = "What ever";
    

    Hard to guess from code fragments, but usually the word “buffer” implies some biggish amount of space that’s going to get reused more than once. You’ve named a character pointer “char_buffer”, but it actually points to a string constant. So, for example, if you later tried to copy 11 characters worth of data to it, then you would overwrite something else (assuming the compiler/linker didn’t store the constant in read-only memory for you).

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

Sidebar

Related Questions

I have a function m(int i, char c) which takes and returns a char
I have this function: void func(int a, int b, char s, FILE *fp, int
I have some function like this: void MClass::GetS(char* buf, int max) const { char
I have this kind of function. function SomeFunction() { const int NUMBER_OF_CONCURENT_THREADS = 50;
I have the following pattern matching case in a scala function: def someFunction(sequences: Iterable[Seq[Int]]):Seq[Int]
I have this function: int firstHeapArray (IntHeapArray h) { if(!emptyHeapArray(h)) return h.array[0]; } It's
suppose we have following function: void someFunction(int * araye){ for (int i=0;i<5;i++) cout <<araye[i]<<'
I have some function, int somefunction( //parameters here, let's say int x) { return
I have defined a delegate like this: delegate void processRecord(int a, int b); now
When doing objective-c, do I have to write out functions like: - (int) someFunction:

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.