{"id":33899185,"url":"https://github.com/harry-ross/c-snippets","last_synced_at":"2026-02-27T02:31:29.313Z","repository":{"id":41505260,"uuid":"193690346","full_name":"Harry-Ross/c-snippets","owner":"Harry-Ross","description":"A simple extension for Visual Studio Code snippets for the C programming language.","archived":false,"fork":false,"pushed_at":"2025-11-12T11:11:26.000Z","size":1129,"stargazers_count":9,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-12T11:11:49.520Z","etag":null,"topics":["c","snippets","visual-studio"],"latest_commit_sha":null,"homepage":"https://marketplace.visualstudio.com/items?itemName=Harry-Ross-Software.c-snippets","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Harry-Ross.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-06-25T10:55:49.000Z","updated_at":"2025-11-12T11:11:30.000Z","dependencies_parsed_at":"2024-05-01T11:34:26.453Z","dependency_job_id":null,"html_url":"https://github.com/Harry-Ross/c-snippets","commit_stats":null,"previous_names":["harry-ross/c-snippets"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/Harry-Ross/c-snippets","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Harry-Ross%2Fc-snippets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Harry-Ross%2Fc-snippets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Harry-Ross%2Fc-snippets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Harry-Ross%2Fc-snippets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Harry-Ross","download_url":"https://codeload.github.com/Harry-Ross/c-snippets/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Harry-Ross%2Fc-snippets/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27670939,"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","status":"online","status_checked_at":"2025-12-11T02:00:11.302Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","snippets","visual-studio"],"created_at":"2025-12-11T22:00:05.718Z","updated_at":"2025-12-11T22:00:10.907Z","avatar_url":"https://github.com/Harry-Ross.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C Snippets\n\nThis extension provides a simple set of VSCode snippets for the C programming language. Can be found [here on the Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=Harry-Ross-Software.c-snippets).\n\n![Visual Studio Marketplace Rating (Stars)](https://img.shields.io/visual-studio-marketplace/stars/Harry-Ross-Software.c-snippets)\n![Visual Studio Marketplace Installs](https://img.shields.io/visual-studio-marketplace/i/Harry-Ross-Software.c-snippets)\n![Visual Studio Marketplace Downloads](https://img.shields.io/visual-studio-marketplace/d/Harry-Ross-Software.c-snippets)\n![GitHub package.json version](https://img.shields.io/github/package-json/v/Harry-Ross/vscode-c-snippets)\n![GitHub repo size](https://img.shields.io/github/repo-size/Harry-Ross/vscode-c-snippets)\n![GitHub](https://img.shields.io/github/license/Harry-Ross/vscode-c-snippets)\n\n# List of snippets:\n| Snippet Description              | Snippet Input | Snippet Code                                                                                               |\n| -----------------------------    | ------------- | ---------------------------------------------------------------------------------------------------------- | \n| Starter Template                 | `sst`         | \u003ccode\u003e#include \u003cstdio.h\u003e\u003cbr\u003eint main (int argc, char *argv[]) { \u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;return 0;\u003cbr\u003e}\u003ccode\u003e |   \n| Starter template with stlib.h    | `libsst`      | \u003ccode\u003e#include \u003cstdio.h\u003e\u003cbr\u003e #include \u003cstdlib.h\u003e \u003cbr\u003eint main (int argc, char *argv[]) { \u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;return 0;\u003cbr\u003e}\u003ccode\u003e |\n| Conditionals and loops | | |\n| If statement| `if` | \u003ccode\u003eif (expression) {\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;/* code here */\u003cbr\u003e}\u003c/code\u003e |\n| Else if statement | `elif` | \u003ccode\u003eelseif (expression) {\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;/* code here */\u003cbr\u003e}\u003c/code\u003e |\n| Else statement | `else` | \u003ccode\u003eelse {\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;/* code here */\u003cbr\u003e}\u003c/code\u003e |\n| For loop | `for` | \u003ccode\u003efor (int i = 0; i \u003c count; i++) {\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;/* code here */\u003cbr\u003e}\u003c/code\u003e |\n| While loop | `while` | \u003ccode\u003ewhile (expression) {\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;/* code here */\u003cbr\u003e}\u003c/code\u003e |\n| Do...while loop | `dowhile` | \u003ccode\u003edo {\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;/* code here */\u003cbr\u003e} while (expression)\u003c/code\u003e | \n| Header file include guard        | `ig`          | \u003ccode\u003e#ifndef {transformed_file_name} \u003cbr\u003e#define {transformed_file_name} \u003cbr\u003e\u003cbr\u003e // Code for header body \u003cbr\u003e\u003cbr\u003e#endif {transformed_file_name}\u003c/code\u003e |\n| Linked lists | | |\n| Linked list template             | `clist`      | \u003ccode\u003etypedef struct _node * Link;\u003cbr\u003etypedef struct _node node;\u003cbr\u003estruct _node {\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;int value;\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;Link next;\u003cbr\u003e};\u003ccode\u003e |\n| Functions | | |\n| Create int function              | `intfunc`     | \u003ccode\u003eint func_name () {\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;int x;\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;return x;\u003cbr\u003e}\u003ccode\u003e |\n| Create float function            | `flfunc`      | \u003ccode\u003efloat func_name () {\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;float x;\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;return x;\u003cbr\u003e}\u003ccode\u003e |\n| Create string function           | `strfunc`     | \u003ccode\u003echar[] func_name () {\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;char[] x = {};\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;return x;\u003cbr\u003e}\u003ccode\u003e |\n| Create long function             | `longfunc`    | \u003ccode\u003elong func_name () {\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;long x;\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;return x;\u003cbr\u003e}\u003ccode\u003e |\n| Create definition for virtual table| `vtdef`     | \u003ccode\u003etypedef struct {ClassName}{ \u003cbr\u003e    struct {ClassNameVT}* vt; \u003cbr\u003e}; \u003cbr\u003e\u003cbr\u003etypedef struct {ClassNameVT} \u003cbr\u003e{ \u003cbr\u003e    // Virtual Table Function definitions \u003cbr\u003e} ${virtualTable Name}; \u003cbr\u003e\u003cbr\u003eint {ClassNameInit}(struct {ClassName} *self); \u003cbr\u003eint {ClassNameDestroy}(struct {ClassName} **self);\u003ccode\u003e |\n| Create function for virtual table| `vtfunc`     | \u003ccode\u003e{ReturnType} (*{FunctionName})(struct {ClassName} *self)\u003ccode\u003e |\n| Print statements | | |\n| Print variable of type float (2 decimal places)   | `pflo`        | \u003ccode\u003eprintf(\\\"var_name :\u003e\u003e %.2f\\\\n\\\", var_name);\u003c/code\u003e |\n| Print variable of type int       | `pint`        | \u003ccode\u003eprintf(\\\"var_name :\u003e\u003e %d\\\\n\\\", var_name);\u003c/code\u003e |\n| Print variable of type char      | `pcha`        | \u003ccode\u003eprintf(\\\"var_name :\u003e\u003e %c\\\\n\\\", var_name);\u003c/code\u003e |\n| Print variable of type pointer   | `ppoint`      | \u003ccode\u003eprintf(\\\"var_name :\u003e\u003e %p\\\\n\\\", (void *) var_name);\u003c/code\u003e |\n| Print variable of type size_t    | `psiz`        | \u003ccode\u003eprintf(\\\"var_name :\u003e\u003e %zu\\\\n\\\", var_name);\u003c/code\u003e |\n| Memory Allocation | | |\n| Allocate memory using calloc     | `cal`         | \u003ccode\u003e{type} *ptr = ({type}*)calloc(, sizeof({type})); \u003cbr\u003eif (ptr == NULL) { \u003cbr\u003e \u0026nbsp;\u0026nbsp;\u0026nbsp;printf(\"Memory allocation failed!\\n\"); \u003cbr\u003e \u0026nbsp;\u0026nbsp;\u0026nbsp;exit(0); \u003cbr\u003e } \u003cbr\u003e free(ptr); \u003c/code\u003e |\n\n\n#### Contributors: [Harry Ross](https://github.com/Harry-Ross) and [Luca Merzetti](https://github.com/lucamerzi)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharry-ross%2Fc-snippets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharry-ross%2Fc-snippets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharry-ross%2Fc-snippets/lists"}