All Questions
Tagged with singly-linked-list struct
203 questions
-1
votes
4
answers
94
views
Incompatible pointer types when declaring a struct [duplicate]
list.h: In function ‘CreateNewLinks’:
list.h:29:20: warning: assignment to ‘numbers *’ from incompatible pointer type ‘struct numbers *’ [-Wincompatible-pointer-types]
29 | linked = ...
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 ...
0
votes
2
answers
96
views
Deleting and inserting nodes in a linked list behave differently (?)
I'm trying to learn linked lists from King (2008) "C Programming: A Modern Approach", 2nd ed and I'm puzzled by the behaviour of the deletion operation as compared to the insertion operation....
-2
votes
2
answers
44
views
Why my stack implementation not working and giving the error "Segmentation fault (core dumped)"
Why my stack implementation not working and giving the error "Segmentation fault (core dumped)"
Here is the code
`
#include <stdio.h>
#include <stdlib.h>
struct node
{
int ...
1
vote
2
answers
54
views
How to avoid getting garbage values while inserting a new node after a given node in singly linked lists?
I was restricted to using only one way of inserting a new node after a given node and implementing the linked list. I was getting a garbage value in my output. I'm not clear on how I can resolve this ...
-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
1
answer
28
views
struct that holds struct, how to dereference
i have couple of linked lists in my larger program which i now want to keep in a struct (t_holder).
typedef struct s_list
{
int val;
struct t_list *next;
} t_list;
typedef struct s_holder
{
...
1
vote
1
answer
89
views
Issue with a first-class linked list implementation in C
I am a newbie at programming at C and I am learning from a book so I apologize if the following is too basic. I am trying to implement first-class linked lists and the following program when executed ...
-1
votes
1
answer
523
views
Error in a simple program of entering elements at beginning of a linkedlist and displaying it in c programming
This is my code for program to enter elements in beginning of a linked list and print the linked list which is working perfectly fine(i am getting correct output for it) -
#include <stdio.h>
#...
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 ...
0
votes
0
answers
64
views
Segmentation fault in C program and stops running further
I am trying to run a link list program in C using Visual Code but after running it, it is giving me a segmentation fault error.
Additionally, it gets stopped on running code.
Code:
#include<stdlib....
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 ...