Skip to content

Instantly share code, notes, and snippets.

View raju249's full-sized avatar
💭
Building BrowserStack

Rajendra kadam raju249

💭
Building BrowserStack
View GitHub Profile
/*
Own code implementated by Rajendra Kadam
Source code is available for download on my website
link: iamrajendra.pythonanywhere.com
*/
#include <stdio.h>
/**
* Tries to delete a number.
*/
void delete(void)
{
// prompt user for number
printf("Number to delete: ");
int n = GetInt();
// get list's first node
/**
* 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
/**
* 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;
/**
* Traverses list, printing its numbers.
*/
void traverse(void)
{
// traverse list
printf("\nLIST IS NOW: ");
node* ptr = first;
while (ptr != NULL)
{
// main entry point for program
int main(void)
{
int c;
do
{
// print instructions
printf("\nMENU\n\n"
"1 - delete\n"
"2 - insert\n"
@raju249
raju249 / linkedlist.c
Last active August 29, 2015 14:25
A linked list in C
// 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