{"id":13895264,"url":"https://github.com/Harry-Ross/vscode-c-snippets","last_synced_at":"2025-07-17T10:33:24.762Z","repository":{"id":41505260,"uuid":"193690346","full_name":"Harry-Ross/vscode-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":"2023-11-05T04:22:08.000Z","size":997,"stargazers_count":7,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-07T18:33:27.249Z","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}},"created_at":"2019-06-25T10:55:49.000Z","updated_at":"2023-11-05T04:22:12.000Z","dependencies_parsed_at":"2024-05-01T11:34:26.453Z","dependency_job_id":null,"html_url":"https://github.com/Harry-Ross/vscode-c-snippets","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Harry-Ross%2Fvscode-c-snippets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Harry-Ross%2Fvscode-c-snippets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Harry-Ross%2Fvscode-c-snippets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Harry-Ross%2Fvscode-c-snippets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Harry-Ross","download_url":"https://codeload.github.com/Harry-Ross/vscode-c-snippets/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226255378,"owners_count":17595859,"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","snippets","visual-studio"],"created_at":"2024-08-06T18:02:05.927Z","updated_at":"2024-11-25T00:31:20.426Z","avatar_url":"https://github.com/Harry-Ross.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"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\nIf you would like to support development of the extension donate Bitcoin here: **1BnrjF49owBx7UjMaJt5crZw5DegUYG3mb**\n#### Authors: [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%2Fvscode-c-snippets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHarry-Ross%2Fvscode-c-snippets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHarry-Ross%2Fvscode-c-snippets/lists"}