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

  • Home
  • SEARCH
  • 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 8883147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:44:44+00:00 2026-06-14T20:44:44+00:00

The program is long(here is the full version: http://pastebin.com/cvg1eSJ1 ), (sample.txt looks like this:

  • 0

The program is long(here is the full version: http://pastebin.com/cvg1eSJ1), (sample.txt looks like this: http://pastebin.com/hWihPpSj, it is the INPUT file, and another command line argument is the output file.) but I am posting the parts dealing with the ‘second pointer list’. Essentially I have a list of 47 or so items, and I need to add items outside of a certain range to a second list. This is where I first save the values. I use “tempAddress” just to clean up the code some. I just take the value at the current address, check it, and if it matches then add it to the second Reading List.

    for (i; i < numElements; i++) {
        tempAddress = firstReadingList++;
        if ((double) *tempAddress > plusOutlier || (double) *tempAddress < minusOutlier) {
            *secondReadingList++ = *tempAddress;

            numOutliers++;
            printf("%d ", *tempAddress);
        }
    }

Later on, I have to write this reading list in another function to a file. I print out the values, and ONLY the last value is incorrect. I have no idea why. Here is the code where I write them to the file(tempAddress is a new variable in this case)

for (i; i < numElements; i++) {
    tempAddress = (outlierList + i);
    printf("%d ", *tempAddress);
    fprintf(out, "%d ", *tempAddress);
}

The output in the first function is as follows:

752 843 840 848 752 850 753 (this is correct)

The second code snippit outputs this

752 843 840 848 752 850 577 (577 is incorrect)

Did I do something wrong? I’m still relatively new to pointers. I DO NOT modify the secondListPointer at any point between functions.

  • 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-14T20:44:45+00:00Added an answer on June 14, 2026 at 8:44 pm

    Before you call get_outliers, you allocate memory for one int:

    int *outlierList = malloc(sizeof *outlierList);
    
    int numOutliers = get_outliers(dataPointer, numReadings, outlierList, average, stdDev, STDDEV_SCALAR);
    

    but there may be more than one outlier. Then you write outside the allocated memory, invoking undefined behaviour, with unforeseeable consequences. Here, just some data was corrupted.

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

Sidebar

Related Questions

I have a program which takes a long time to complete. I would like
I have a long-running multithreaded program, and I'd like to occasionally like to call
I have a program, that takes a long time to load. Because of this,
I'm using some long values as bitmaps in a Java program. Here's my method
I'm getting back into c after a long hiatus. Here's a little program I've
I have program that runs for long periods of time and I'd like to
I have a method like this: private async Task DoSomething() { // long running
Actually my system gives Long.MAX_VALUE as 9223372036854775807 But when I write my program like
The following short Fortran90 program crashes as long as it contains the MPI_GET call.
I need to make a program that adds long integers without using the biginteger

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.