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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:04:09+00:00 2026-06-11T11:04:09+00:00

I keep constantly getting a segmentation error with a small portion of code and

  • 0

I keep constantly getting a segmentation error with a small portion of code and I have no idea why, I’m using malloc and cant see any reason with that, just as soono as it hits the portion of data, its crashes.
The Data is:

listNode* node = (listNode*)malloc(sizeof(listNode));    <-This is the Line
strcpy(node->entry, string); 
node->next = NULL;

Using the struct definition:

typedef struct
{
    char* entry;
    struct listNode* next;
}listNode;

The data does get freed at one point, however it cannot reach said point.
Thanks for the help!

  • 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-11T11:04:10+00:00Added an answer on June 11, 2026 at 11:04 am

    You didn’t allocate memory for the entry pointer. You’re trying to copy your string to a bogus location specified by the uninitialized pointer entry. You might do this instead:

    node->entry = malloc(strlen(string) + 1);
    strcpy(node->entry, string);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the code belowin the environment.rb and i keep getting the error uninitialized
I keep getting this error: uninitialized constant GetxmlController::Xmlparse my code for the class looks
In this code I keep getting an error, I know its how I'm saving
I have this header file ... for some reason I keep getting an error
I'm trying to send SMTP e-mails using PHPMailer, but I keep getting this error
I keep getting this error when I compile and run my Java program using
Keep getting this error after inserting a subdatasheet into a query and trying to
Keep getting the error Arguments are not sufficiently instantiated for the multiplication by addition
I keep getting an error saying that @android:style/Widget.Holo.Light.Button.Borderless is not public and so can't
I keep getting this error after cloning a repository from the AndEngine project.. The

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.