<commit_before>#include <stdio.h>
#include <stdlib.h>

typedef struct node_struct
{
    int number;
    struct node_struct *next;
}
node;

/* Practice List
 * [ ] Print a linked list
 * [x] Create a new node
 * [ ] Find a new node
 * [ ] Insert a node after a value
 * [ ] Insert a node at a specific pointer
 * [ ] Delete a node
 */

void PrintLinkedList(node *head);
node *CreateNode(int value);

int main()
{
    node *head = NULL;
    node *tmp = NULL;

    for (int i = 1; i <= 5; i++)
    {
        tmp = CreateNode(i);
        tmp->next = head;
        head = tmp;
    }

    PrintLinkedList(head);

    return 0;
}

/**
 * @brief  
 * @note   
 * @param  *list: 
 * @param  value: 
 * @retval 
 */
node *FindNode(node *list, int value)
{
    //TODO: create a func that returns a pointer to a node that contains a specific value
    return NULL;
}

/**
 * @brief  Creates a new node in HEAP setting the next and number values
 * @note   
 * @param  value: numeric data you want to place in the node
 * @retval 
 */
node *CreateNode(int value)
{
    node *tmp = malloc(sizeof(node));
    tmp->number = value;
    tmp->next = NULL;

    return tmp;
}

/**
 * @brief  
 * @note   
 * @param  *head: 
 * @retval None
 */
void PrintLinkedList(node *head)
{
    node *tmp = head;
    while(tmp != NULL)
    {
        printf("%i\n", tmp->number);
        tmp = tmp->next;
    }
}<commit_msg>finished FindNode() function<commit_after>#include <stdio.h>
#include <stdlib.h>

typedef struct node_struct
{
    int number;
    struct node_struct *next;
}
node;

/* Practice List
 * [x] Print a linked list
 * [x] Create a new node
 * [x] Find a new node
 * [ ] Insert a node after a value
 * [ ] Insert a node at a specific pointer
 * [ ] Delete a node
 */

void PrintLinkedList(node *head);
node *CreateNode(int value);
node *FindNode(node *list, int value);

int main()
{
    node *head = NULL;
    node *tmp = NULL;

    for (int i = 1; i <= 5; i++)
    {
        tmp = CreateNode(i);
        tmp->next = head;
        head = tmp;
    }

    // debug FindNode()
    node *test = FindNode(head, 2);
    if (test == NULL)
    {
        printf("test pointer returned NULL\n");
        return 1;
    }
    printf("Found (test->number): %i\n", test->number);

    return 0;
}

/**
 * @brief  Find a node with a specified value
 * @note   
 * @param  *list: Pointer to the head of the linked list you wish to search through
 * @param  value: Integer value you are looking for in the linked list
 * @retval Pointer to a node containing the value (null if not found)
 */
node *FindNode(node *list, int value)
{
    node *target = NULL;
    while (list != NULL)
    {
        if (list->number == value)
            target = list;

        // iterate to the next node in the list
        list = list->next;
    }
    
    return target;
}

/**
 * @brief  Creates a new node in HEAP setting the next and number values
 * @note   
 * @param  value: numeric data you want to place in the node
 * @retval 
 */
node *CreateNode(int value)
{
    node *tmp = malloc(sizeof(node));
    tmp->number = value;
    tmp->next = NULL;

    return tmp;
}

/**
 * @brief  Prints the content of the linked list in the console starting at the head
 * @note   
 * @param  *head: Pointer to a linked list starting at the head of the list
 * @retval None
 */
void PrintLinkedList(node *head)
{
    node *tmp = head;
    while(tmp != NULL)
    {
        printf("%i\n", tmp->number);
        tmp = tmp->next;
    }
}
{'fraction_non_alphanumeric': 0.12726228095374892, 'fraction_numerical': 0.002298190175237001, 'mean_word_length': 2.3838678328474248, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4099400', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1125, 'n_words': 419}