{"id":25171325,"url":"https://github.com/basemax/stackc","last_synced_at":"2025-07-16T07:47:57.733Z","repository":{"id":151535585,"uuid":"573530105","full_name":"BaseMax/StackC","owner":"BaseMax","description":"This is a simple stack implementation in C, using an array as the underlying data structure. It's possible to resize the stack, and it's possible to set the initial size of the stack.","archived":false,"fork":false,"pushed_at":"2022-12-02T17:52:06.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-11T12:49:43.868Z","etag":null,"topics":["c","c-stack","data-structure","datastructure","stack","stack-c","stack-implementation"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BaseMax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-12-02T17:25:37.000Z","updated_at":"2022-12-04T20:30:28.000Z","dependencies_parsed_at":"2023-07-10T14:15:22.789Z","dependency_job_id":null,"html_url":"https://github.com/BaseMax/StackC","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BaseMax/StackC","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FStackC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FStackC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FStackC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FStackC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BaseMax","download_url":"https://codeload.github.com/BaseMax/StackC/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FStackC/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265493434,"owners_count":23776251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","c-stack","data-structure","datastructure","stack","stack-c","stack-implementation"],"created_at":"2025-02-09T09:19:52.110Z","updated_at":"2025-07-16T07:47:57.723Z","avatar_url":"https://github.com/BaseMax.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stack C\r\n\r\nThis is a simple stack implementation in C, using an array as the underlying data structure. It's possible to resize the stack, and it's possible to set the initial size of the stack.\r\n\r\n## Functions\r\n\r\n- `Stack* newStack(int size)`: Create a new stack with a given size.\r\n- `bool isFull(Stack* stack)`: Check if the stack is full.\r\n- `bool isEmpty(Stack* stack)`: Check if the stack is empty.\r\n- `void push(Stack* stack, int item)`: Push an item onto the stack.\r\n- `int pop(Stack* stack)`: Pop an item off the stack.\r\n- `int peek(Stack* stack)`: Peek at the top of the stack.\r\n- `void printStack(Stack* stack)`: Print the stack.\r\n- `void destroyStack(Stack* stack)`: Destroy the stack.\r\n- `char* stackToString(Stack* stack)`: Convert the stack to a string.\r\n- `Stack* resizeStack(Stack* stack, int size)`: Resize the stack to a new size.\r\n\r\n## Usage\r\n\r\n```c\r\n// Create a stack of capacity 5\r\nStack* stack = newStack(5);\r\n\r\n// Push items to stack\r\npush(stack, 1);\r\npush(stack, 2);\r\npush(stack, 3);\r\npush(stack, 4);\r\npush(stack, 5);\r\n\r\npush(stack, 100);\r\n\r\n// Check if stack is full\r\nif (isFull(stack)) {\r\n    printf(\"Stack is full!\\n\");\r\n}\r\n\r\n// Print the stack\r\nprintStack(stack);\r\n\r\n// Resize the stack\r\nstack = resizeStack(stack, 10);\r\n\r\n// Push an item to stack\r\npush(stack, 100);\r\n\r\n// Print the stack\r\nprintStack(stack);\r\n\r\n// Pop items from stack\r\npop(stack);\r\npop(stack);\r\n\r\n// Convert the stack to string\r\nchar* str = stackToString(stack);\r\nprintf(\"%s\\n\", str);\r\n\r\n// Check if the stack is empty\r\nif (isEmpty(stack)) {\r\n    printf(\"Stack is empty!\\n\");\r\n} else {\r\n    printf(\"Stack is not empty!\\n\");\r\n}\r\n\r\n// Peek the top item from stack\r\nprintf(\"Top item: %d\\n\", peek(stack));\r\n\r\n// Destroy the stack\r\ndestroyStack(stack);\r\n\r\n// Print the stack\r\nprintf(\"%s\\n\", stackToString(stack));\r\n\r\n// Check if the stack is empty\r\nif (isEmpty(stack)) {\r\n    printf(\"Stack is empty!\\n\");\r\n} else {\r\n    printf(\"Stack is not empty!\\n\");\r\n}\r\n```\r\n\r\nCopyright Max Base, 2022\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Fstackc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasemax%2Fstackc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Fstackc/lists"}