All Questions
46 questions
1
vote
2
answers
131
views
linked list problem when displaying the list in C
having segmentation error while trying to access nodes
i can create new nodes with my add function after function executes i cant access my nodes. i think they deallocated in memory but i couldnt ...
-2
votes
2
answers
51
views
Why is this c linked list deletion at head program not printing the desired output?
// c program to delete first node..
// input size:3
// input elements:1,2,3
// desired output:2->3->NULL
// actual output:1->NULL
#include <stdio.h>
#include <stdlib.h>
struct ...
0
votes
2
answers
113
views
error: member access with misaligned address
I am working on problem 2 in leetcode (Two Sum) and I keep getting this error.
I don't understand how this reflects what I wrote:
here is my code that I wrote, I think it has something to do with the ...
1
vote
3
answers
128
views
Loop for Linked Lists
I really like this implementation of code but I don't want it to be hardcoded so can someone help me to make a loop for list = new_node(1); and so forth.
#include <stdlib.h>
#include <stdio.h&...
0
votes
2
answers
51
views
Trying to delete node from a particular position . But I can only delete when in only input position 1 in the terminal
after running the code ,the program ask the position from where you want to delete a node . I ran the code but it only work when I input postion 1 .For other position like 2,3,4 it does not work .
...
0
votes
2
answers
185
views
Why this function is not able to reverse the Linked List?
I want to reverse a linked list but when i compile this code it terminates unexpectedly.
#include <bits/stdc++.h>
using namespace std;
class node{
public:
int data;
node* next;
...
0
votes
1
answer
52
views
My linked list is giving segmentation faults after i delete an element and try to display my phone book
I'm trying to create a telephone directory and I'm having issues with my delete_pr function. the function's name itself explains what it is supposed to do pretty much. When I create a record using ...
0
votes
1
answer
398
views
Getting the nth from last of the linked list
What I'm doing is that first I reversed the linked list and then actually I'm trying to get the nth value of a node. The problem is that the function isn't doing anything after it reverses the linked ...
0
votes
2
answers
136
views
How implement the removal of elements with even numbers from the created stack?
How implement the removal of elements with even numbers from the created stack? Here is the code. I'm not well versed in this topic yet. I ask for help.
I need to implement the removal of elements ...
1
vote
1
answer
118
views
How to add a new node to a linked list alphabetically
I am trying to build a music library with five songs using a linked list, and each song has three tags, the songName, the Artist and the Genre. So I take users' input and add it to the linked list, ...
-1
votes
5
answers
1k
views
accessing struct members using pointer to pointer
I have a program like below, when I try to access a struct member using pointer to pointer it says the expression must have a pointer to class type. Please tell me how can I access data element of the ...
1
vote
2
answers
1k
views
Function to insert a node in a linked list in C
I'm trying to learn data structures in C and I'm stuck at the first function I made.
If I run this nothing happens.
I get no errors but the program doesn't print anything.
#include <stdio.h>
#...
0
votes
1
answer
82
views
(C) Inserting into a Linked List struct is not reflecting within other functions
I am attempting to insert nodes into the head of a Linked List object, but the updated head does not appear to reflect in other functions.
My professor has dictated that our insert functions need a ...
1
vote
1
answer
578
views
Deleting all nodes smaller than x in singly linked list in c
I making a program that the lets the user enter countless integers until the number 0 is entered, then display and sort it from smallest to largest. Code:
#include <stdio.h>
#include <stdlib....
1
vote
2
answers
375
views
Leetcode:Merge Two Sorted Lists. I don't know where the link is wrong
I would like to ask why this link list will not run the result. After running, it is TLE. I want the head to be an indicator, and the head list can be returned without modifying the head.
/**
* ...