Skip to content

Instantly share code, notes, and snippets.

@CarterZenke
Last active October 21, 2024 10:18
Show Gist options
  • Save CarterZenke/f9aa3a11b380694560b929d078b1cc94 to your computer and use it in GitHub Desktop.
Save CarterZenke/f9aa3a11b380694560b929d078b1cc94 to your computer and use it in GitHub Desktop.
#include <cs50.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct node
{
string phrase;
struct node *next;
}
node;
#define LIST_SIZE 2
bool unload(node *list);
void visualizer(node *list);
int main(void)
{
node *list = NULL;
// Add items to list
for (int i = 0; i < LIST_SIZE; i++)
{
string phrase = get_string("Enter a new phrase: ");
// TODO: add phrase to new node in list
// Visualize list after adding a node.
visualizer(list);
}
// Free all memory used
if (!unload(list))
{
printf("Error freeing the list.\n");
return 1;
}
printf("Freed the list.\n");
return 0;
}
bool unload(node *list)
{
// TODO: Free all allocated nodes
return false;
}
void visualizer(node *list)
{
printf("\n+-- List Visualizer --+\n\n");
while (list != NULL)
{
printf("Location %p\nPhrase: \"%s\"\nNext: %p\n\n", list, list->phrase, list->next);
list = list->next;
}
printf("+---------------------+\n\n");
}
@SomRandomGuy
Copy link

Gj

@Mtubail
Copy link

Mtubail commented Mar 5, 2024

Thanks bro....
How to debug my code now ?!

@TManeth
Copy link

TManeth commented Mar 25, 2024

hi how r u guys doing

@abdulajalaly
Copy link

when i tried to clone this file into cs50 codespace it says that I don't have permission to do so, is there any way to do that

@yas8say
Copy link

yas8say commented Apr 24, 2024

when i tried to clone this file into cs50 codespace it says that I don't have permission to do so, is there any way to do that

just copy/paste it

@HideOnTheBushh
Copy link

this guy is a legend

@NerdyTaha
Copy link

thanks

@Kyorzo
Copy link

Kyorzo commented Jun 17, 2024

W

@AndrewCarson5
Copy link

Nicee

@Jibbothelakerman
Copy link

Thanks for this!

@moussatra
Copy link

all good

@siddydiallo2009
Copy link

great

@HazemThePro
Copy link

Great

@michellelynnpenney
Copy link

Thanks! ☺

@xrp-amaebi
Copy link

...

@auguscab27
Copy link

great

@JuniorMhlanga
Copy link

Great stuff

@ProfShibe
Copy link

ayo mistah white

@J0n4ld
Copy link

J0n4ld commented Aug 26, 2024

How to properly download it at Codespace?

@siddydiallo2009
Copy link

siddydiallo2009 commented Aug 26, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment