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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:53:01+00:00 2026-06-15T22:53:01+00:00

I have come to a problem where I try to use while loop on

  • 0

I have come to a problem where I try to use while loop on linked list.
I have two linked lists, namely temp and graph. I am using a while loop to do tasks while(temp != NULL). To move on in each of the loop, I am assigning temp = temp->link. However, this code does not compile. I realize that recursive function could be a solution, but the function is actually way more complicated that I don’t think recursive would be such a good idea. By the way, graph is already a built linked list. Thanks in advance!

P.S. It is part of homework.

temp = graph->link;
while(temp!=NULL){
    if(stack->link == NULL){
        stack->link = (node_pointer)malloc(sizeof(graph));
        stack->link->weight = temp->weight;
        stack->link->vertex = temp->vertex;
    }
    temp = temp->link; //Here is the problem.
}

edit:

stack and graph are both arrays of linked list:

typedef struct node *node_pointer;

struct node{
    int vertex;
    int weight;
    int visited;
    struct node *link;
};
node_pointer graph[50];
node_pointer stack[50];
node_pointer temp;
  • 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-15T22:53:02+00:00Added an answer on June 15, 2026 at 10:53 pm

    0xC00000005 is not a compile time error. This error usually happens when you access a memory location that you’re not allowed to, even if its pointing to NULL. Its a runtime error. Check to see if temp is not NULL and is also malloced properly. Is it? Also check all other variables. Use a debugger, run it through valgrind. It will help you learn the language and debugging techniques properly. Especially CompileTime and RuntimeErrors ;-).

    Also explicitly make link as NULL when creating a new node. Pointer variables usually contain a JUNK value without initialization. I am assuming you’re not setting link to NULL and accessing a JUNK memory location. Garbage in Garbage out. Your logic of IF TEMP(WHICH IS SET TO LINK) IS NOT EQUAL TO NULL fails if LINK is not null but is junk.

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

Sidebar

Related Questions

I am using $SUB for the first time and have come across this problem.
I have come across an annoying problem while writing some PHP4 code. I renamed
I have come across quite a wired problem right now. I am using ASP.NET
I am currently learning to use java script, and have come across a problem
I have come to a problem, wich I have no idea how to solve.
I have come across a problem. There are N piles of stones where the
I am new to sql and I have come across a problem on joining
I've started learning JSF2.0, and have come across a problem. Any advice on how
I have come across an annoying problem. I have made a system and now
I have come across a strange problem which I would like to get your

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.