{"id":16471941,"url":"https://github.com/abranhe/cs50","last_synced_at":"2025-04-30T14:30:40.086Z","repository":{"id":96043421,"uuid":"157180431","full_name":"abranhe/cs50","owner":"abranhe","description":"The CS50 Library for C ready to use with Clib","archived":false,"fork":false,"pushed_at":"2021-10-12T02:35:38.000Z","size":17,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-06T02:22:22.439Z","etag":null,"topics":["c","c-library","clib","clibs","cs50"],"latest_commit_sha":null,"homepage":"https://cs50.readthedocs.io/library/c/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abranhe.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}},"created_at":"2018-11-12T08:29:51.000Z","updated_at":"2024-06-19T03:53:03.000Z","dependencies_parsed_at":"2023-11-17T14:34:02.986Z","dependency_job_id":null,"html_url":"https://github.com/abranhe/cs50","commit_stats":null,"previous_names":["abrahamhba/cs50","abranhe/cs50"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abranhe%2Fcs50","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abranhe%2Fcs50/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abranhe%2Fcs50/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abranhe%2Fcs50/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abranhe","download_url":"https://codeload.github.com/abranhe/cs50/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251721381,"owners_count":21632827,"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-library","clib","clibs","cs50"],"created_at":"2024-10-11T12:15:37.107Z","updated_at":"2025-04-30T14:30:39.741Z","avatar_url":"https://github.com/abranhe.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\t\u003cbr\u003e\n\t\u003cimg src=\"https://avatars3.githubusercontent.com/u/788676?s=200\"\u003e\n\t\u003cbr\u003e\n\t\u003cbr\u003e\n\t\u003cbr\u003e\n\t\u003cb\u003ecs50\u003c/b\u003e: The CS50 Library for C ready to use with \u003ca href=\"https://github.com/clibs/clib/\"\u003eClib\u003c/a\u003e\n\t\u003cbr\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\t\u003ca href=\"https://travis-ci.org/abranhe/cs50\"\u003e\n\t\t\u003cimg src=\"https://img.shields.io/travis/abranhe/cs50.svg?logo=travis\"/\u003e\n\t\u003c/a\u003e\n  \u003cbr\u003e\n  \u003cbr\u003e\n\u003c/p\u003e\n\n## Description\n\nI was a [CS50](https://cs50.harvard.edu) student once, working with strings was easier back then while coding in C. So why not keep using it on future projects?\n\nWell, I created this project to integrate it [Clib](https://github.com/clibs/clib) and to be easy to use as a dependency for future projects.\n\n###### Keep in mind\n\nIf you are a CS50 student don't take this project as example to follow the style, make sure you read instead [the style guide for the C Programming Language](https://cs50.readthedocs.io/style/c/) from CS50.\n\n## Installation\n\n*Installing using [Clib](https://github.com/clibs/clib)*\n\n```sh\n$ clib install abranhe/cs50\n```\n\nFor more installation options see the [official library][cs50] from the CS50 team.\n\n## Usage\n\n```\n$ ./example\nabranhe\nhello, abranhe\n```\n\n###### example.c\n\n```c\n#include \u003cstdio.h\u003e\n#include \"cs50.h\"\n\nint main()\n{\n\tstring s = get_string();\n\tprintf(\"hello, %s\\n\", s);\n\treturn 0;\n}\n```\n\n## API\n\n#### `string`\n\n*Type representing a C string. Aliased to* `char *`.\n\n#### `void eprintf(const char *format, ...)`\n\n*Prints an error message formatted like `printf()` to standard error, prefixing it with file and line number from which the function was called.*\n\n###### Params:\n\n- `format` - the `printf()`-like format string used to display the prompt\n- `...` – values to be substituted into the format string a la `printf()`\n\n#### `char get_char(const char *format, ...)`\n\n*Prompts user for a line of text from standard input and returns the equivalent `char`; if text does not represent a single char, user is reprompted.*\n\n###### Params:\n\n- `format` - the `printf()`-like format string used to display the prompt\n- `...` – values to be substituted into the format string a la `printf()`\n\n###### Returns:\n\n- the char equivalent to the line read from stdin, or `CHAR_MAX` on error\n\n#### `double get_double(const char *format, ...)`\n\n*Prompts user for a line of text from standard input and returns the equivalent `double`; if text does not represent a double or would cause overflow or underflow, user is reprompted.*\n\n###### Params:\n\n- `format` - the `printf()`-like format string used to display the prompt\n- `...` – values to be substituted into the format string a la `printf()`\n\n###### Returns:\n\n- the double equivalent to the line read from stdin in [`DBL_MIN`, `DBL_MAX`), as precisely as possible, or `DBL_MAX` on error\n\n#### `int get_int(const char *format, ...)`\n\n*Prompts user for a line of text from standard input and returns the equivalent `int`; if text does not represent an int or would cause overflow, user is reprompted.*\n\n###### Params:\n\n- `format` - the `printf()`-like format string used to display the prompt\n- `...` – values to be substituted into the format string a la `printf()`\n\n###### Returns:\n\n- the int equivalent to the line read from stdin in [`INT_MIN`, `INT_MAX`) or `INT_MAX` on error\n\n#### `float get_float(const char *format, ...)`\n\n*Prompts user for a line of text from standard input and returns the equivalent float; if text does not represent a `float` or would cause overflow or underflow, user is reprompted.*\n\n###### Params:\n\n- `format` - the `printf()`-like format string used to display the prompt\n- `...` – values to be substituted into the format string a la `printf()`\n\n###### Returns:\n\n- the float equivalent to the line read from stdin in [`FLT_MIN`, `FLT_MAX`), as precisely as possible, or `FLT_MAX` on error\n\n#### `long get_long(const char *format, ...)`\n\n*Prompts user for a line of text from standard input and returns the equivalent float; if text does not represent a `long` or would cause overflow or underflow, user is reprompted.*\n\n###### Params:\n\n- `format` - the `printf()`-like format string used to display the prompt\n- `...` – values to be substituted into the format string a la `printf()`\n\n###### Returns:\n\n- the float equivalent to the line read from stdin in [`LONG_MIN`, `LONG_MAX`), as precisely as possible, or `LONG_MAX` on error\n\n#### `char *get_string(const char *format, ...)`\n\n*Prompts user for a line of text from standard input and returns it as a string (char *), sans trailing line ending. Supports CR (`\\r`), LF (`\\n`), and CRLF (`\\r\\n`) as line endings. Stores string on heap, but library’s destructor frees memory on program’s exit.*\n\n###### Params:\n\n- `format` - the `printf()`-like format string used to display the prompt\n- `...` – values to be substituted into the format string a la `printf()`\n\n###### Returns:\n\n- the read line as a string sans line endings, or `NULL` on `EOF`.\n\nFor more information read the documentation at [cs50.readthedocs.io/library/c](https://cs50.readthedocs.io/library/c/)\n## Related\n\n- [cs50][cs50]: Official CS50 Library for C\n\n## License\n\nThe CS50 library is owned and managed by the Team behind CS50, [learn more](cs50).\n\n\u003c!-------------------- Links ------------------------\u003e\n[abranhe]: https://github.com/abranhe\n[abranhe-img]: https://avatars3.githubusercontent.com/u/21347264?s=50\n[license]: https://github.com/abranhe/cs50/blob/master/license\n[example]: https://github.com/abranhe/cs50/blob/master/example.c\n[cs50]: https://github.com/cs50/libcs50\n[travis-badge]: https://img.shields.io/travis/abranhe/cs50.svg\n[travis-status]: https://travis-ci.org/abranhe/cs50\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabranhe%2Fcs50","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabranhe%2Fcs50","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabranhe%2Fcs50/lists"}