This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Own code implementated by Rajendra Kadam | |
Source code is available for download on my website | |
link: iamrajendra.pythonanywhere.com | |
*/ | |
#include <stdio.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Tries to delete a number. | |
*/ | |
void delete(void) | |
{ | |
// prompt user for number | |
printf("Number to delete: "); | |
int n = GetInt(); | |
// get list's first node |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Searches for a number in list. | |
*/ | |
void search(void) | |
{ | |
// prompt user for number | |
printf("Number to search for: "); | |
int n = GetInt(); | |
// get list's first node |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Tries to insert a number into list. | |
*/ | |
void insert(void) | |
{ | |
// try to instantiate node for number | |
node* newptr = malloc(sizeof(node)); | |
if (newptr == NULL) | |
{ | |
return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Traverses list, printing its numbers. | |
*/ | |
void traverse(void) | |
{ | |
// traverse list | |
printf("\nLIST IS NOW: "); | |
node* ptr = first; | |
while (ptr != NULL) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// main entry point for program | |
int main(void) | |
{ | |
int c; | |
do | |
{ | |
// print instructions | |
printf("\nMENU\n\n" | |
"1 - delete\n" | |
"2 - insert\n" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is the code for linked list in C. | |
// This includes functions for insert,delete,search and traverse | |
// I used the distribution code from my course CS50 by Porf.David.J.Malan | |
#include <cs50.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
// Defines a node for linked list | |
typedef struct node |