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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:50:22+00:00 2026-06-02T02:50:22+00:00

Im just trying to get started with learning C http://fromlearncodethehardway.com . However I’m stuck

  • 0

Im just trying to get started with learning C http://fromlearncodethehardway.com. However I’m stuck with a segmentation fault while trying to code up one of the examples from there. Here’s the link to my source code.
I tried using valgrind to further help with the debugging but I cant seem to figure out the issue. Here’s the stack trace from valgrind.

   ~/Chardway$ valgrind ./ex17 db.dat g
   ==4423== Memcheck, a memory error detector                                                                                 == 4423== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
 ==4423== Using Valgrind-3.6.1-Debian and LibVEX; rerun with -h for copyright info
 ==4423== Command: ./ex17 db.dat g
 ==4423== 
 ==4423== Invalid read of size 1
 ==4423==    at 0x4EA4F1D: _IO_file_fopen@@GLIBC_2.2.5 (fileops.c:271)
 ==4423==    by 0x4E99DB5: __fopen_internal (iofopen.c:93)
 ==4423==    by 0x400A76: Database_open (ex17.c:65)
 ==4423==    by 0x400F7C: main (ex17.c:151)
 ==4423==  Address 0x722b is not stack'd, malloc'd or (recently) free'd
 ==4423== 
 ==4423== 
 ==4423== Process terminating with default action of signal 11 (SIGSEGV)
 ==4423==  Access not within mapped region at address 0x722B
 ==4423==    at 0x4EA4F1D: _IO_file_fopen@@GLIBC_2.2.5 (fileops.c:271)
 ==4423==    by 0x4E99DB5: __fopen_internal (iofopen.c:93)
 ==4423==    by 0x400A76: Database_open (ex17.c:65)
  ==4423==    by 0x400F7C: main (ex17.c:151)
.....

  ==4423== For counts of detected and suppressed errors, rerun with: -v
  ==4423== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 4 from 4)
 Segmentation fault

Any help on debugging would be great. Thanks!

  • 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-02T02:50:23+00:00Added an answer on June 2, 2026 at 2:50 am

    In your code you have fopen calls as fopen(filename,'w'); & fopen(filename,'r+');. Those should be fopen(filename,"w"); & fopen(filename,"r+");. The second parameter to fopen should be const char *
    Hope this helps!

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

Sidebar

Related Questions

I'm just trying to get started with Java EE and related concepts. However, I'm
I just started learning Prism and trying to use it with MEF in a
So I just started learning haskell and I'm trying to use this if statement:
Just started learning mvc3. I've built a fairly basic website (also using EF-Code-First if
I have just started learning Erlang and am trying out some Project Euler problems
Started learning javascript yesterday at CodeAcademy and decided I could actually write code. Just
i just started learning how lucene works and am trying to implement it in
I just started trying my hands on EF4 code first this morning and I
I'm new to JSP, using Eclipse, and am trying to just get started with
I just started learning about servers, and I am messing around with Google's App

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.