GithubHelp home page GithubHelp logo

stack's Introduction

Stack

This is my first experience in data structures!
image

Main commands

Constructor and destructor

Constructs and destructs stack:

stack *myCoolStack = stackConstructor(1);
stackDestructor(myCoolStack);

Push and pop

Pushes / pops value in / out of stack:

stackPush(myCoolStack, 10);

elem_t myCoolElement = 0;
stackPop(myCoolStack, &myCoolElement);

Dump

Dumps info about stack in terminal:

stackDump(myCoolStack);
simpleStackDump(myCoolStack);

Quick Start

First clone repo:

git clone "https://github.com/flopsreallygotit/Stack.git"

Then switch to Stack/Example/ and write:

make
./main

Good job! Now you can watch an example and then use it!

Try to hack this!

image

Push & Pop & Good Luck & Have Fun!

stack's People

Contributors

flopsreallygotit avatar

Stargazers

Nik avatar  avatar Aleksander Morozov avatar

Watchers

 avatar

stack's Issues

Wrong README

Hi, flopsreallygotit!

I was curious how freshmen solve tasks by Ded this year. So I tried to install your stack according to README. Unfortunately, I failed because of a mistake in your building manual.

Look what I've got:
issue

Hope you'll fix this.

With best regards, KetchuppOfficial

You've been hacked :-)

Hi, flopsreallygotit!

Don't worry, I figured out how to build and run your program (but it would be nice to fix README anyway). Unfortunately, it's incredibly easy to hack your stack. Look at this code:

#include "stackUtils.h"
#include "math.h"

int main ()
{   
    stack good_luck = {};
    stackConstructor (&good_luck, 10);
    good_luck.data = NULL;
    stackDestructor (&good_luck);

    return 0;
}

The result is beloved segmentation fault :-)

I recommend you to learn something about encapsulation and how it should be implemented in C. You can start here: https://en.wikipedia.org/wiki/Encapsulation_(computer_programming).

With best regards, KetchuppOfficial

Memory leaks

Hi, flopsreallygotit!

I tested your stack on the given example. Sadly, I noticed bad memory leaks:
Screenshot from 2022-11-01 01-40-23

Hope you'll add all missing free() calls.

With best regards, KetchuppOfficial

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.