Delete all the targets in linked list in c [on hold]Designing function prototypes for a singly-linked list...

Why is "points exist" not an axiom in geometry?

Why is working on the same position for more than 15 years not a red flag?

Why doesn't "auto ch = unsigned char{'p'}" compile under C++ 17?

Why zero tolerance on nudity in space?

We are very unlucky in my court

Is it a fallacy if someone claims they need an explanation for every word of your argument to the point where they don't understand common terms?

Contest math problem about crossing out numbers in the table

Why Normality assumption in linear regression

Are there any modern advantages of a fire piston?

It took me a lot of time to make this, pls like. (YouTube Comments #1)

Why are the books in the Game of Thrones citadel library shelved spine inwards?

What's a good word to describe a public place that looks like it wouldn't be rough?

How would one buy a used TIE Fighter or X-Wing?

Am I a Rude Number?

Difference between two similar commands to activate a Python venv

Can a hotel cancel a confirmed reservation?

Why did other German political parties disband so fast when Hitler was appointed chancellor?

Disable the ">" operator in Rstudio linux terminal

How to acknowledge an embarrassing job interview, now that I work directly with the interviewer?

What makes the Forgotten Realms "forgotten"?

What kind of hardware implements Fourier transform?

What to do when being responsible for data protection in your lab, yet advice is ignored?

Magento 2 : Call Helper Without Using __construct in Own Module

Calculate Contact age in a Drupal view



Delete all the targets in linked list in c [on hold]


Designing function prototypes for a singly-linked list API in CLinked List Delete Node FunctionDelete duplicates in a linked ListSimplifying linked list “search and delete” functionDelete duplicates from unsorted linked listDelete an item from a linked listSingly linked list delete() methodLinked List design and implementation - C++Delete all occurrences of an item in linked listDoubly-linked list program with delete functions













-2












$begingroup$


#include <stdio.h>
#include <stdlib.h>
typedef struct _node {
int data;
struct _node * next;
} node_t;

typedef struct {
node_t * head;
node_t * tail;
} LL_t;
LL_t * LLcreate() {
LL_t * ret = malloc(sizeof(LL_t));
ret->head = NULL;
ret->tail = NULL;
return ret;
}
void LLappend(LL_t * intlist, int value) {
node_t * newNode = malloc(sizeof(node_t));

newNode->data = value;
newNode->next = NULL;

if (intlist->head == NULL) {
intlist->head = newNode;
intlist->tail = newNode;
} else {
intlist->tail->next = newNode;
intlist->tail = newNode;
}
}
void Remove(LL_t * intlist, int target){
node_t *current=intlist->head;
node_t *previous=NULL;
int temp=0;
while (current !=NULL){
if (current->data==target){
if(previous==NULL){
intlist->head=current->next;
}
else{
previous->next=current->next;
}
temp=1;
}
if(previous==NULL){
previous=intlist->head;
current=current->next;
}
else{
previous=current;
current=current->next;
}
}
if(temp==0){
printf("The taget is not in the linked list");
}

}
void LLprint(LL_t *intlist){
for(node_t *current=intlist->head;current!=NULL;current=current->next){
printf("%dn",current->data);
}
}

int main(int argc, const char * argv[]) {
LL_t *intlist=LLcreate();
LLappend(intlist, 332);
LLappend(intlist, 12);
LLappend(intlist, 23);
LLappend(intlist, 23);
LLappend(intlist, 22);
LLappend(intlist, 23);
Remove(intlist, 23);
LLprint(intlist);
return 0;
}


My list is 332 23 12 23 23 22. The out put is 332 12 23 22. But it should be 323 12 22.



The function can remove the element if it only happens once or the multiple targets show in the list are not in a row. Who can help me fix the Function? Thanks!










share|improve this question









New contributor




cici is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$



put on hold as off-topic by 1201ProgramAlarm, 200_success, Edward, Sᴀᴍ Onᴇᴌᴀ, ferada 2 days ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – 200_success, Edward, Sᴀᴍ Onᴇᴌᴀ

If this question can be reworded to fit the rules in the help center, please edit the question.












  • 1




    $begingroup$
    I would be nice if the example could compile instead of guessing everything in your list structure.
    $endgroup$
    – Bo R
    2 days ago










  • $begingroup$
    edited. Thanks!
    $endgroup$
    – cici
    2 days ago






  • 1




    $begingroup$
    Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
    $endgroup$
    – Edward
    2 days ago










  • $begingroup$
    strongly suggest moving this question to stackoverflow.com
    $endgroup$
    – user3629249
    2 days ago
















-2












$begingroup$


#include <stdio.h>
#include <stdlib.h>
typedef struct _node {
int data;
struct _node * next;
} node_t;

typedef struct {
node_t * head;
node_t * tail;
} LL_t;
LL_t * LLcreate() {
LL_t * ret = malloc(sizeof(LL_t));
ret->head = NULL;
ret->tail = NULL;
return ret;
}
void LLappend(LL_t * intlist, int value) {
node_t * newNode = malloc(sizeof(node_t));

newNode->data = value;
newNode->next = NULL;

if (intlist->head == NULL) {
intlist->head = newNode;
intlist->tail = newNode;
} else {
intlist->tail->next = newNode;
intlist->tail = newNode;
}
}
void Remove(LL_t * intlist, int target){
node_t *current=intlist->head;
node_t *previous=NULL;
int temp=0;
while (current !=NULL){
if (current->data==target){
if(previous==NULL){
intlist->head=current->next;
}
else{
previous->next=current->next;
}
temp=1;
}
if(previous==NULL){
previous=intlist->head;
current=current->next;
}
else{
previous=current;
current=current->next;
}
}
if(temp==0){
printf("The taget is not in the linked list");
}

}
void LLprint(LL_t *intlist){
for(node_t *current=intlist->head;current!=NULL;current=current->next){
printf("%dn",current->data);
}
}

int main(int argc, const char * argv[]) {
LL_t *intlist=LLcreate();
LLappend(intlist, 332);
LLappend(intlist, 12);
LLappend(intlist, 23);
LLappend(intlist, 23);
LLappend(intlist, 22);
LLappend(intlist, 23);
Remove(intlist, 23);
LLprint(intlist);
return 0;
}


My list is 332 23 12 23 23 22. The out put is 332 12 23 22. But it should be 323 12 22.



The function can remove the element if it only happens once or the multiple targets show in the list are not in a row. Who can help me fix the Function? Thanks!










share|improve this question









New contributor




cici is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$



put on hold as off-topic by 1201ProgramAlarm, 200_success, Edward, Sᴀᴍ Onᴇᴌᴀ, ferada 2 days ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – 200_success, Edward, Sᴀᴍ Onᴇᴌᴀ

If this question can be reworded to fit the rules in the help center, please edit the question.












  • 1




    $begingroup$
    I would be nice if the example could compile instead of guessing everything in your list structure.
    $endgroup$
    – Bo R
    2 days ago










  • $begingroup$
    edited. Thanks!
    $endgroup$
    – cici
    2 days ago






  • 1




    $begingroup$
    Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
    $endgroup$
    – Edward
    2 days ago










  • $begingroup$
    strongly suggest moving this question to stackoverflow.com
    $endgroup$
    – user3629249
    2 days ago














-2












-2








-2





$begingroup$


#include <stdio.h>
#include <stdlib.h>
typedef struct _node {
int data;
struct _node * next;
} node_t;

typedef struct {
node_t * head;
node_t * tail;
} LL_t;
LL_t * LLcreate() {
LL_t * ret = malloc(sizeof(LL_t));
ret->head = NULL;
ret->tail = NULL;
return ret;
}
void LLappend(LL_t * intlist, int value) {
node_t * newNode = malloc(sizeof(node_t));

newNode->data = value;
newNode->next = NULL;

if (intlist->head == NULL) {
intlist->head = newNode;
intlist->tail = newNode;
} else {
intlist->tail->next = newNode;
intlist->tail = newNode;
}
}
void Remove(LL_t * intlist, int target){
node_t *current=intlist->head;
node_t *previous=NULL;
int temp=0;
while (current !=NULL){
if (current->data==target){
if(previous==NULL){
intlist->head=current->next;
}
else{
previous->next=current->next;
}
temp=1;
}
if(previous==NULL){
previous=intlist->head;
current=current->next;
}
else{
previous=current;
current=current->next;
}
}
if(temp==0){
printf("The taget is not in the linked list");
}

}
void LLprint(LL_t *intlist){
for(node_t *current=intlist->head;current!=NULL;current=current->next){
printf("%dn",current->data);
}
}

int main(int argc, const char * argv[]) {
LL_t *intlist=LLcreate();
LLappend(intlist, 332);
LLappend(intlist, 12);
LLappend(intlist, 23);
LLappend(intlist, 23);
LLappend(intlist, 22);
LLappend(intlist, 23);
Remove(intlist, 23);
LLprint(intlist);
return 0;
}


My list is 332 23 12 23 23 22. The out put is 332 12 23 22. But it should be 323 12 22.



The function can remove the element if it only happens once or the multiple targets show in the list are not in a row. Who can help me fix the Function? Thanks!










share|improve this question









New contributor




cici is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$




#include <stdio.h>
#include <stdlib.h>
typedef struct _node {
int data;
struct _node * next;
} node_t;

typedef struct {
node_t * head;
node_t * tail;
} LL_t;
LL_t * LLcreate() {
LL_t * ret = malloc(sizeof(LL_t));
ret->head = NULL;
ret->tail = NULL;
return ret;
}
void LLappend(LL_t * intlist, int value) {
node_t * newNode = malloc(sizeof(node_t));

newNode->data = value;
newNode->next = NULL;

if (intlist->head == NULL) {
intlist->head = newNode;
intlist->tail = newNode;
} else {
intlist->tail->next = newNode;
intlist->tail = newNode;
}
}
void Remove(LL_t * intlist, int target){
node_t *current=intlist->head;
node_t *previous=NULL;
int temp=0;
while (current !=NULL){
if (current->data==target){
if(previous==NULL){
intlist->head=current->next;
}
else{
previous->next=current->next;
}
temp=1;
}
if(previous==NULL){
previous=intlist->head;
current=current->next;
}
else{
previous=current;
current=current->next;
}
}
if(temp==0){
printf("The taget is not in the linked list");
}

}
void LLprint(LL_t *intlist){
for(node_t *current=intlist->head;current!=NULL;current=current->next){
printf("%dn",current->data);
}
}

int main(int argc, const char * argv[]) {
LL_t *intlist=LLcreate();
LLappend(intlist, 332);
LLappend(intlist, 12);
LLappend(intlist, 23);
LLappend(intlist, 23);
LLappend(intlist, 22);
LLappend(intlist, 23);
Remove(intlist, 23);
LLprint(intlist);
return 0;
}


My list is 332 23 12 23 23 22. The out put is 332 12 23 22. But it should be 323 12 22.



The function can remove the element if it only happens once or the multiple targets show in the list are not in a row. Who can help me fix the Function? Thanks!







c linked-list






share|improve this question









New contributor




cici is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




cici is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago







cici













New contributor




cici is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









cicicici

11




11




New contributor




cici is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





cici is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






cici is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as off-topic by 1201ProgramAlarm, 200_success, Edward, Sᴀᴍ Onᴇᴌᴀ, ferada 2 days ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – 200_success, Edward, Sᴀᴍ Onᴇᴌᴀ

If this question can be reworded to fit the rules in the help center, please edit the question.







put on hold as off-topic by 1201ProgramAlarm, 200_success, Edward, Sᴀᴍ Onᴇᴌᴀ, ferada 2 days ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – 200_success, Edward, Sᴀᴍ Onᴇᴌᴀ

If this question can be reworded to fit the rules in the help center, please edit the question.








  • 1




    $begingroup$
    I would be nice if the example could compile instead of guessing everything in your list structure.
    $endgroup$
    – Bo R
    2 days ago










  • $begingroup$
    edited. Thanks!
    $endgroup$
    – cici
    2 days ago






  • 1




    $begingroup$
    Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
    $endgroup$
    – Edward
    2 days ago










  • $begingroup$
    strongly suggest moving this question to stackoverflow.com
    $endgroup$
    – user3629249
    2 days ago














  • 1




    $begingroup$
    I would be nice if the example could compile instead of guessing everything in your list structure.
    $endgroup$
    – Bo R
    2 days ago










  • $begingroup$
    edited. Thanks!
    $endgroup$
    – cici
    2 days ago






  • 1




    $begingroup$
    Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
    $endgroup$
    – Edward
    2 days ago










  • $begingroup$
    strongly suggest moving this question to stackoverflow.com
    $endgroup$
    – user3629249
    2 days ago








1




1




$begingroup$
I would be nice if the example could compile instead of guessing everything in your list structure.
$endgroup$
– Bo R
2 days ago




$begingroup$
I would be nice if the example could compile instead of guessing everything in your list structure.
$endgroup$
– Bo R
2 days ago












$begingroup$
edited. Thanks!
$endgroup$
– cici
2 days ago




$begingroup$
edited. Thanks!
$endgroup$
– cici
2 days ago




1




1




$begingroup$
Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
$endgroup$
– Edward
2 days ago




$begingroup$
Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
$endgroup$
– Edward
2 days ago












$begingroup$
strongly suggest moving this question to stackoverflow.com
$endgroup$
– user3629249
2 days ago




$begingroup$
strongly suggest moving this question to stackoverflow.com
$endgroup$
– user3629249
2 days ago










0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Fairchild Swearingen Metro Inhaltsverzeichnis Geschichte | Innenausstattung | Nutzung | Zwischenfälle...

Pilgersdorf Inhaltsverzeichnis Geografie | Geschichte | Bevölkerungsentwicklung | Politik | Kultur...

Marineschifffahrtleitung Inhaltsverzeichnis Geschichte | Heutige Organisation der NATO | Nationale und...