Skip to content

How to make a linked list in C without using the arrow operator.

Notifications You must be signed in to change notification settings

codenoschool/linked-list-no-arrows-in-c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Introduction

This projects aims for creating a linked list data structure while using no arrow operator to access structure members in the C programing language.

While it's a common things to access the members of a structure trough a pointer by using the arrow operator, how could we answer the following question:

  • How to access the members of a structure trough a pointer but without using the arrow operator?

And even more complicated...

  • How can we access the members of a structure referenced in a pointer of a structure trough a pointer?

Well... This project provides the source code of a program in the C language where you'll see the answer to those questions.

Features

The following features (functions) are avaible in the source code:

  • Print the linked list.
  • Push a new node at the beginning (as new head) of the list.
  • Push a new node at the end (at the tail) of the list.
  • Pop a node at the beginning (head) of the list.
  • Pop a node at the end (tail) of the list.
  • Pop a node at certain position (index) in the list.
  • Pop a node by certain value (data) in the list.

How to compile and run the program

Running the program is pretty easy:

  • Clone this repository
  • A C compilator; gcc 10.2.0 was used for this, though this project will likely compile just wine by using older versions of gcc.
  • Compile the source code
  • Run the program by executing ./ll-noarrows.

Demonstratiton:

# Clone this repository
git clone https://github.com/codenoschool/linked-list-no-arrows-in-c
# Move inside the cloned repository
cd linked-list-no-arrows-in-c
# Compile the source code
gcc main.c
# Run the program
./ll-noarrows

Alternatively, instead of using gcc (or other C compiler) you can do:

# Compile the source code
make
# Delete the program
make clean
# Delethe the program and re-compile the source code
make remake

Such rules are defined inside the file Makefile and can be changed if needed.

... And that's it.

How to use

Simply compile the source code and execute the program. Some instructions have been already being defined inside the main function of program, so they could be changed or you could also add new functionality.

Credits and refereces

This repository was created by CodeNoSchool.

About

How to make a linked list in C without using the arrow operator.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published