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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:38:20+00:00 2026-05-26T10:38:20+00:00

EDIT: About to try intilizing my chars properly… [didnt work=( ] EDIT: SOLVED (I

  • 0

EDIT: About to try intilizing my chars properly… [didnt work=( ]

EDIT: SOLVED (I can’t answer my own question for another 7 hours…)

Thanks for the comment Brian, that’s just a constant declared at the top.. (it = 20).

It turns out the error was happening because I forgot to add a next line after I took in the input name.

it’s working now =D

:ENDEDIT (lol)

I’ve code my code below, Basically I put in the first name this is supposed to find

John

Then I put in the last name…

Locke

and as soon as I enter in “Locke” it hits this error, I feel like maybe it’s the scanf and I should be using a better alternative ???

int findPatron(struct Library *lib,struct Patron **p)
{
    int i;
    char firstName[NAME_LENGTH], lastName[NAME_LENGTH];
    printf("\nPlease enter the patron's first name: ");
    scanf("%s",firstName);
    printf("\nPlease enter the patron's last name:  "); //this line prints...
    scanf("%s",lastName);  //SEGMENTATION ERROR happens here I'm pretty sure.
    printf("deerrrr");  //this line never prints
     for(i = 0; i<lib->totalPatrons;i++)
    {
            printf("checking %s %s to %s %s",lib->patrons[i].name.first,lib->patrons[i].name.last,firstName,lastName);
            if((strcmp(lib->patrons[i].name.first, firstName) == 0) && (strcmp(lib->patrons[i].name.last, lastName) == 0))
            {
                    **p = lib->patrons[i];
                    return 0;
                    break;
            }
    }

    return 1;  //No Match!
}
  • 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-26T10:38:21+00:00Added an answer on May 26, 2026 at 10:38 am

    You’re getting the segmentation fault after your scanf() statements.

    If you remove everything after printf("deerrrr"); and add a \n to that output so the buffer is flushed, you’ll find that it all works just fine (provided NAME_LENGTH is at least 6 given your example input).

    Part of programming is knowing how to isolate and debug your problems.

    Your issues are with your loop and lib struct – you’re dereferencing something you shouldn’t be.

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

Sidebar

Related Questions

Edit: From another question I provided an answer that has links to a lot
EDIT: This question is more about language engineering than C++ itself. I used C++
EDIT: This question is about finding definitive reference to MySQL syntax on SELECT modifying
My question is about line (edit: 19), where the new PrintWriter is created with
EDIT: Original Title: Question about the benefit of using an ORM. I want to
First I do know about 'import'. When I try 'import' it doesn't work. What
EDIT: I would really like to see some general discussion about the formats, their
I'm about to start a project that will record and edit audio files, and
EDIT: This post was originally specific to ASP.NET, but after thinking about it I'm
Edit: When I say SQL Server, I'm really talking about the Management Studio. Sorry

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.