how to change the value of a node in a linked list in c
typedef struct node{
int value; //this is the value the node stores
struct node *next; //this is the node the current node points to. this is how the nodes link
}node;
node *ammendValue(node *head, int index, int val){
node *tmp = head;
int count = 0;
//if the user enters an index greater then the length of the list
if(index > len(head)){
return NULL;
}
//if the last value needs editing
if(index == -1){
while(count < len(head)-1){
tmp = tmp->next;
count += 1;
}
tmp->value = val;
return head;
}
//if the first value needs editing
if(index == 0){
head->value = val;
return head;
}
//for any other case
while(count < index){
tmp = tmp->next;
count += 1;
}
tmp->value = val;
return head;
}
Also in C:
- how to login to docker inside kubernetes cluster
- c memcpy array
- table fixed header
- multiplication operator in c
- a enum data type in c
- how to transfer textbox fro string to integer vb.net
- modelform prefill with data
- Search Code Snippets
- function in c
- bash: apt-add-repository: command not found
- vue cdn
- learn assembly language
- lazer codechef
- powershell some fonts like #include are dissapearing
- grep with color highlight
- passing 2d array as parameter to function in c
- error 403
- c rand range
- download file by command line windows
- object fit cover
- c hello world
- c return
- fopen c
- pygame draw transparent rectangle