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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:54:16+00:00 2026-05-19T14:54:16+00:00

This my program where it takes 10 integers and finds out if even or

  • 0

This my program where it takes 10 integers and finds out if even or odd and stores them in respective files.I use gcc.

#include<stdio.h>
int main()
{
int a,i;
FILE *fp1,*fp2,*fp3;
fp1=fopen("data","w");
for(i=0;i<10;i++)
{
scanf("%d",&a);
putw(a,fp1);
}
fclose(fp1);
fp1=fopen("data","r");
fp2=fopen("even","w");
fp3=fopen("odd","w");
while((a=getw(fp1))!=EOF)
if(a%2==0)
putw(a,fp2);
else
putw(a,fp3);
fclose(fp1);
fclose(fp2);
fclose(fp1);
return 0;
}

I get this after entering the 10 values

*** glibc detected *** ./a.out: double free or corruption (!prev): 0x09b79008 ***
======= Backtrace: =========
/lib/libc.so.6(+0x6c501)[0x17c501]
/lib/libc.so.6(+0x6dd70)[0x17dd70]
/lib/libc.so.6(cfree+0x6d)[0x180e5d]
/lib/libc.so.6(fclose+0x14a)[0x16c81a]
./a.out[0x80485e4]
/lib/libc.so.6(__libc_start_main+0xe7)[0x126ce7]
./a.out[0x8048421]
======= Memory map: ========
00110000-00267000 r-xp 00000000 08:04 686829     /lib/libc-2.12.1.so
00267000-00268000 ---p 00157000 08:04 686829     /lib/libc-2.12.1.so
00268000-0026a000 r--p 00157000 08:04 686829     /lib/libc-2.12.1.so
0026a000-0026b000 rw-p 00159000 08:04 686829     /lib/libc-2.12.1.so
0026b000-0026e000 rw-p 00000000 00:00 0 
007b2000-007ce000 r-xp 00000000 08:04 686805     /lib/ld-2.12.1.so
007ce000-007cf000 r--p 0001b000 08:04 686805     /lib/ld-2.12.1.so
007cf000-007d0000 rw-p 0001c000 08:04 686805     /lib/ld-2.12.1.so
009cc000-009cd000 r-xp 00000000 00:00 0          [vdso]
00a2c000-00a46000 r-xp 00000000 08:04 686863     /lib/libgcc_s.so.1
00a46000-00a47000 r--p 00019000 08:04 686863     /lib/libgcc_s.so.1
00a47000-00a48000 rw-p 0001a000 08:04 686863     /lib/libgcc_s.so.1
08048000-08049000 r-xp 00000000 08:04 753598     /home/bobby/Desktop/c/a.out
08049000-0804a000 r--p 00000000 08:04 753598     /home/bobby/Desktop/c/a.out
0804a000-0804b000 rw-p 00001000 08:04 753598     /home/bobby/Desktop/c/a.out
09b79000-09b9a000 rw-p 00000000 00:00 0          [heap]
b7600000-b7621000 rw-p 00000000 00:00 0 
b7621000-b7700000 ---p 00000000 00:00 0 
b77df000-b77e0000 rw-p 00000000 00:00 0 
b77ea000-b77eb000 rw-p 00000000 00:00 0 
b77ed000-b77f0000 rw-p 00000000 00:00 0 
bfed2000-bfef3000 rw-p 00000000 00:00 0          [stack]
Aborted

I want to know what is it.This is first time i got a error of this kind.I want to understand the error and find out what is wrong with my program.

  • 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-05-19T14:54:16+00:00Added an answer on May 19, 2026 at 2:54 pm

    You are closing fp1 twice. Look at the last line before return 🙂

    I suspect you want to close fp3 instead, if I’ve interpreted your program correctly. There’s also a clue in the stacktrace, the error happens somewhere inside fclose.

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

Sidebar

Related Questions

I have this program in c++: #include <iostream> using namespace std; int main() {
I just translated this program, #include <stdio.h> int dam[1000][1000]; int main (int argc, const
I expected A::~A() to be called in this program, but it isn't: #include <iostream>
There's this program, pdftotext, that can convert a pdf file to a text file.
Can someone please explain why this program outputs 0x00000004? class AndAssignment { static void
Okay, I have this program and I don't want more than one instance of
I have an executable that is started by a windows service, this program will
Consider this Python program which uses PyGtk and Hippo Canvas to display a clickable
Why does this test program result in a java.lang.IllegalMonitorStateException ? public class test {
I am writing this java program to find all the prime numbers up to

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.