{"id":50873756,"url":"https://github.com/mr-thearch/flowgorithm-c-template","last_synced_at":"2026-06-15T07:33:20.224Z","repository":{"id":324550839,"uuid":"1097572077","full_name":"mr-thearch/flowgorithm-c-template","owner":"mr-thearch","description":"Unofficial Flowgorithm language template for the C programming language. Generates valid C99 code from Flowgorithm flowcharts, including support for strings, booleans, typed input, array handling, and full expression translation.","archived":false,"fork":false,"pushed_at":"2025-11-16T14:14:02.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-16T16:11:54.458Z","etag":null,"topics":["c-language","c-template","code-generation","compiler","education","flowgorithm","teaching","template"],"latest_commit_sha":null,"homepage":"","language":null,"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/mr-thearch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2025-11-16T12:47:01.000Z","updated_at":"2025-11-16T14:14:05.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mr-thearch/flowgorithm-c-template","commit_stats":null,"previous_names":["mr-thearch/flowgorithm-c-template"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/mr-thearch/flowgorithm-c-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-thearch%2Fflowgorithm-c-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-thearch%2Fflowgorithm-c-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-thearch%2Fflowgorithm-c-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-thearch%2Fflowgorithm-c-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mr-thearch","download_url":"https://codeload.github.com/mr-thearch/flowgorithm-c-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-thearch%2Fflowgorithm-c-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34353193,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","response_time":63,"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-language","c-template","code-generation","compiler","education","flowgorithm","teaching","template"],"created_at":"2026-06-15T07:33:19.509Z","updated_at":"2026-06-15T07:33:20.219Z","avatar_url":"https://github.com/mr-thearch.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flowgorithm C Language Template\n\nThis repository contains an unofficial **Flowgorithm language template for C**, created to allow students to translate flowcharts into fully compilable C programs.  \nThe project is intended for **educational use**, with an emphasis on clarity, predictability, and adherence to standard C (C99+).\n\nThe template provides:\n- A complete `.fpgt` file that integrates C into Flowgorithm's code-generation system.\n- Several helper functions required to support strings, booleans, and typed input.\n- Example Flowgorithm programs (in the `Examples/` folder) together with their generated C code.\n\nThe goal is to offer a reliable tool that mirrors as closely as possible the behaviour of Flowgorithm’s internal interpreter, while still producing valid and idiomatic C code suitable for beginners learning the language.\n\n---\n\n## Purpose of This Template\n\nFlowgorithm officially supports languages such as C#, Java, Python, and C++.  \nHowever, it lacks a native C generator.  \nThis template fills that gap by implementing:\n\n- Type mappings from Flowgorithm → C  \n- Expression translation  \n- Function generation (with and without return values)  \n- Array declaration  \n- String and boolean emulation  \n- Typed input and formatted output  \n- Helper functions for string conversion, concatenation, numeric parsing, and boolean parsing\n\nThe generated code targets a **minimal and didactically clean subset of C**, avoiding pointers, dynamic structures, or advanced features unless they are strictly required to emulate Flowgorithm semantics.\n\n---\n\n## Challenges in Translating Flowgorithm to C\n\nC is a low-level language that lacks many of the high-level features available in Flowgorithm or languages like C# and Java.  \nTo maintain compatibility with Flowgorithm's execution model, several non-trivial problems had to be solved.\n\nBelow is an overview of the main design challenges and the chosen solutions.\n\n---\n\n### 1. Typed Input and Conversion Functions\n\nFlowgorithm accepts user input interactively and converts it to the proper type.  \nC does not provide such behaviour natively, therefore this template defines custom helpers:\n\n- `inputValue()` — reads a full line and parses it as `double`\n- `inputInt()` — parses an integer\n- `inputBool()` — parses a boolean using Flowgorithm’s rules\n- `inputString()` — reads an entire line, preserving spaces\n\nParsing is done using `fgets()` combined with `strtod`, `strtol`, or custom string analysis.  \nThis ensures that invalid input does not break the program: instead, the functions loop until a valid value is provided, reproducing Flowgorithm’s behaviour as closely as possible.\n\n---\n\n### 2. Boolean Support\n\nIn standard C, booleans are extremely primitive (`bool` from `\u003cstdbool.h\u003e` is just an integer).  \nFlowgorithm, instead, uses the strings `\"true\"` and `\"false\"` during input and output.\n\nTo match this behaviour:\n\n- Boolean input accepts only `\"true\"` or `\"false\"` (case-insensitive, no spaces).\n- Boolean output prints exactly `\"true\"` or `\"false\"`.\n- Internally, C still stores booleans as `bool`.\n\nThis approach preserves the Flowgorithm model without confusing beginners about how booleans work in real-world C code.\n\n---\n\n### 3. String Handling\n\nStrings are the most delicate part of the translation.  \nFlowgorithm treats strings as high-level immutable values.  \nC, instead, has only null-terminated byte arrays, without automatic resizing or concatenation.\n\nThis template implements:\n\n- All strings as `char*` obtained via `malloc`\n- A safe `stringConcat(const char*, const char*)` that returns newly allocated strings\n- `inputString()` that dynamically allocates and returns the full user input\n- `toString(double)` using a static buffer for temporary conversions, as expected in C\n\nThis makes string expressions like:\n\nresult = \"literal one\" + s1 + \"literal two\" + s2\n\n\nwork correctly, even when chained.\n\nMemory is intentionally not freed automatically so as not to overwhelm beginners with memory management: Flowgorithm itself assumes automatic lifetime.\n\n---\n\n### 4. Array Size: Limitations of C\n\nFlowgorithm supports an intrinsic function `Size(array)`.\n\nIn C, however:\n\n- Array length can be computed using `sizeof(array) / sizeof(array[0])`\n- **But only inside the same scope where the array is declared**\n- When an array is passed to a function, it decays to a pointer (`int*`, `double*`, etc.), losing all size information.\n\nFor this reason, the first release adopts a simple didactic rule:\n\n\u003e Arrays are declared using standard C syntax, but `Size(array)` is only valid in the scope of the declaration.  \n\u003e When calling user-defined functions, the programmer must explicitly pass the number of elements.\n\nExample:\n\n```c\nvoid bubbleSortInt(int a[], int n);\n\nint arr[20];\nint n = Size(arr);         // Works here\nbubbleSortInt(arr, n);     // n must be forwarded\n```\n\nThis limitation reflects the true behaviour of the C language and helps students learn correct array handling.\n\n## Repository structure\n\n```\nflowgorithm-c-template/\n│\n├── C.fpgt                # The actual Flowgorithm language template for C\n├── Examples/             # Flowgorithm sample files + generated C output\n├── README.md             # Documentation (this file)\n└── LICENSE               # Open-source license\n```\n\n## Contributing\n\nContributions are welcome.\nSeveral areas can be extended or improved:\n\n- Memory-safe string utilities\n- Richer output formatting\n- Optional free() calls for advanced users\n- Support for file I/O\n- More robust boolean parsing\n- Extended math library integration\n- Improvements to nested function generation\n\nFeel free to open issues or pull requests.\n\n## License\nThis project is released under the MIT License.\nYou are free to fork, extend, and redistribute it.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmr-thearch%2Fflowgorithm-c-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmr-thearch%2Fflowgorithm-c-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmr-thearch%2Fflowgorithm-c-template/lists"}