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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:41:23+00:00 2026-06-10T01:41:23+00:00

After debugging i get this error message : HEAP CORRUPTION DETECTED after normal block

  • 0

After debugging i get this error message : HEAP CORRUPTION DETECTED after normal block (#55). If I increse the size of the array (no_of_days+1), it’s working, but i don’t know if it’s right.
What i am doing wrong?

int main()
{

    int no_of_days=0;
    int no_operations=0;
    int *a;
    int i;
    FILE *pfile1=NULL;
    FILE *pfile2=NULL;
    char *filename1="input.txt";
    char *filename2="output.txt";

    pfile1=fopen(filename1, "r");
    if(pfile1==NULL)
    {
        printf("Error on opening the file %s.",filename1);
        return 0;
    }
    fscanf(pfile1,"%d%d",&no_of_days,&no_operations);
    a=(int*)malloc((no_of_days)*sizeof(int));
    if(a==NULL)
    {
        printf("Memory allocation failed.");
        return 0;
    }
    for(i=1;i<=no_of_days;i++)
    {
        fscanf(pfile1,"%d",&a[i]);
    }
    pfile2=fopen(filename2,"a");
    if(pfile2==NULL)
    {
        printf("Memory allocation failed!",filename2);
    }
    for(i=1;i<=no_of_days;i++)
    {
        fprintf(pfile2,"%d",a[i]);
    }
    free(a);
    fclose(pfile1);
    fclose(pfile2);
  • 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-10T01:41:25+00:00Added an answer on June 10, 2026 at 1:41 am
    a=(int*)malloc((no_of_days)*sizeof(int));
    /* ... */
    for(i=1;i<=no_of_days;i++)
    

    Indexing starts from 0 so accessing a[no_of_days] is illegal. Change that for line to:

    for(i = 0; i < no_of_days; i++)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this error after debugging in Eclipse. The debug is successful though. ERROR:
I get this error when debugging my ASP.NET web application after I trigger an
I have no idea why this error is occurring after debugging the project even
Every so often when I'm debugging, I get this message in nice brown text
After hours I am giving up on debugging the following: This works: URL[] urls
After deploying WCF server (svc) on my Server, I have got this message when
I'm getting the following error after I start debugging my program. Do you know
Well since i installed IE 8 i get this error so i cant debug
I get this strange error child pid 1789 exit signal Bus error (10) I
After debugging for a few hours, the algorithm seems to be working. Right now

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.