{"id":20637077,"url":"https://github.com/travorlzh/cppstuff","last_synced_at":"2025-03-09T06:38:23.620Z","repository":{"id":162217231,"uuid":"119210246","full_name":"TravorLZH/cppstuff","owner":"TravorLZH","description":"Some C/C++ basics and algorithms","archived":false,"fork":false,"pushed_at":"2019-06-19T23:42:24.000Z","size":43,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-17T08:13:18.612Z","etag":null,"topics":["algorithm","c","c-language","cmake","cplusplus","cpp","factorization"],"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/TravorLZH.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}},"created_at":"2018-01-27T23:07:14.000Z","updated_at":"2021-10-18T09:03:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"429add00-b9d4-4fe5-a205-9d6778f41ef9","html_url":"https://github.com/TravorLZH/cppstuff","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/TravorLZH%2Fcppstuff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TravorLZH%2Fcppstuff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TravorLZH%2Fcppstuff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TravorLZH%2Fcppstuff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TravorLZH","download_url":"https://codeload.github.com/TravorLZH/cppstuff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242656036,"owners_count":20164431,"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":["algorithm","c","c-language","cmake","cplusplus","cpp","factorization"],"created_at":"2024-11-16T15:12:54.561Z","updated_at":"2025-03-09T06:38:23.601Z","avatar_url":"https://github.com/TravorLZH.png","language":"C","readme":"C/C++ Demonstration\n=======\nThis is the first repository I created in C++. I have been writing programs in C language for years. Some of them are even written with `cpp` extension. But I have never used some C++ features. So in this repo, I would like to show you some examples of C++ STL.\n\n\u003e You should prepare all the libraries needed in order to generate Makefiles\n\n## Miscellaneous Executables\n\n* **vectordemo**: A demonstration of `std::vector`. It's something similar to an array. But it contains more methods. It simply prints out everything inside the array.\n* **regexdemo**: A demonstration of **POSIX BRE** written in C language using **libgnurx** because I can't use the standard **C++11**'s regex library in **MinGW**.\n* **posixeredemo**: A demonstration of **POSIX ERE** which stands for Extended Regular Expression, written in C language too. I recently discovered that the only difference is to add REG\\_EXTENDED in `cflags`.\n* **globalctors**: A demonstration of **GCC Global Constructor**: A function that is automatically called before **main**.\n* **cpudemo**: A x86-specific demonstration of getting CPU information using `cpuid`\n\n## Mathematics\n\n* **factor**: This helps you factor any expressions that is in **ax\u003csup\u003e2\u003c/sup\u003e+bx+c** format. Following is the possible output\n```\nmain: enter coefficient for: ax^2+bx+c\na=12\nb=-7\nc=-12\nmain: Processing 12x^2-7x-12...\n(3x-4)(4x+3)\n```\n* **squareroot**: Re-implementation of sqrt()\nIt uses the following steps to get the possible accurate value:\n1. Guess a value called G\n1. Check if G is close enough to the input/G\n1. Return G if true, otherwise goto 1\n* **binarysearch**: An implementation of searching node in an array with least comparisons.\n\n## Structures\n\n* **bitfield**: A program that shows the value of struct with bitfield in the memory\n```\nstruct{\n\tchar a:1;\n\tchar b:1;\n\tchar c:1;\n\tchar d:2;\n} bitfield;\n```\n* **structdemo**: A program that shows difference between packed struct and default (aligned) struct.\n\n## Libraries\n\n* **libvoid**: A set of functions that demonstrates generic type `void*`.\n\n| Function Prototypes | Description |\n|:------|:------|\n| void swap(void\\* ap,void\\* bp,size\\_t sz) | Switch the values between two generic pointers. |\n| void\\* lsearch(void\\* key,void\\* base,size\\_t n,size\\_t each) | Search stuff from an unknown type array and returns the address of the result. |\n| void\\* lsearchx(void\\* key,void\\* base,size\\_t n,size\\_t each,cmpfunc cmp) | Same as **lsearch**, but with a custom function for comparing values |\n\n### Demonstrations of libvoid\n\n* **swapdemo**: Demonstration of **swap()**.\n* **searchdemo**: Demonstration of **lsearch()**.\n* **customcmpsearch**: Demonstration of **lsearchx()**.\n\n## Networking\n\n* **ipaddr**: A tool to get IP address from your machine\n* **ftpdemo**: Demonstration of FTP Protocol\n\n\u003e Compile with `-DVERBOSE` helps show the response from server\n\n## Documents\n\n* **man\\_regex.txt**: regular expression manual from Linux. I got function prototypes here.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftravorlzh%2Fcppstuff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftravorlzh%2Fcppstuff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftravorlzh%2Fcppstuff/lists"}