{"id":17358373,"url":"https://github.com/subhash3/bit-arrays-in-c","last_synced_at":"2025-06-21T05:02:50.944Z","repository":{"id":174673952,"uuid":"287500748","full_name":"Subhash3/bit-arrays-in-c","owner":"Subhash3","description":"Bit manipulations in c","archived":false,"fork":false,"pushed_at":"2020-08-16T06:01:37.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-25T20:02:54.558Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Subhash3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-08-14T09:54:04.000Z","updated_at":"2020-11-12T13:16:01.000Z","dependencies_parsed_at":"2023-07-30T06:15:17.662Z","dependency_job_id":null,"html_url":"https://github.com/Subhash3/bit-arrays-in-c","commit_stats":null,"previous_names":["subhash3/bit-arrays-in-c"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Subhash3/bit-arrays-in-c","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Subhash3%2Fbit-arrays-in-c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Subhash3%2Fbit-arrays-in-c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Subhash3%2Fbit-arrays-in-c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Subhash3%2Fbit-arrays-in-c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Subhash3","download_url":"https://codeload.github.com/Subhash3/bit-arrays-in-c/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Subhash3%2Fbit-arrays-in-c/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261065252,"owners_count":23104762,"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":[],"created_at":"2024-10-15T19:05:14.745Z","updated_at":"2025-06-21T05:02:45.932Z","avatar_url":"https://github.com/Subhash3.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Bit Manipulations in C\n\n#### Bit array structure:\n```c\nstruct BitArray\n{\n    int bitsNeeded;\n    int arraySize;\n    unsigned int array[]; // Flexible Array\n};\ntypedef  struct  BitArray  BitArray;\n```\n#### Usage\n##### Create a BitArray object\n```c\nBitArray *bitArray =  NULL;\n```\n##### Initialize the bit array\n```c\n// Function Prototype\nBitArray *initBitArray(BitArray **bitArr, int bitsNeeded);\n/*\n  Creates a bit array.\n  Returns a pointer to the newly created BitArray object on success and NULL on failure.\n*/\n\n\nBitArray *initBitArrayWithInteger(BitArray **bitArr, int bitsNeeded, int integer);\n/*\n  Creates a bit array.\n  Returns a BitArray object(with each byte set to integer) on success and NULL on failure.\n  If the provided integer doens't fit within the specified bits, then the most significant bits will be neglected.'\n*/\n\n// Eg.\nint bitsNeeded = 10; // No. of bits you want to work with\nbitArray =  initBitArray(\u0026bitArray, bitsNeeded);\n\n    OR\nnum = 5\nbitArray =  initBitArrayWithInteger(\u0026bitArray, bitsNeeded, num);\n```\n##### Bit Operations\n```c\nbool setBit(BitArray **bitArr, int k);\n/* \n  Sets the (k-1)th bit (to 1). \n  Returns true on success and false on failure.\n*/\n\nbool clearBit(BitArray **bitArr, int k);\n/* \n  Clears the (k-1)th bit (makes it 0).\n  Returns true on success and false on failure.\n*/\n\nbool isBitSet(BitArray **bitArr, int k);\n/*\n  Checks of the (k-1)th bit is set(1) or not(0).\n  Returns true if set and false otherwise.\n*/\n\nbool toggleBit(BitArray **bitArr, int k);\n/* \n  Toggles the (k-1)th bit (makes it 0 if 1 and 1 if 0)\n  Returns true on success and false on failure.\n*/\n\nvoid printBitArray(BitArray **bitArr);\n/*\n  Prints the bit array as a binary string (of 1s and 0s).\n*/\n\nvoid clearAllBits(BitArray **bitArr);\n/*\n  Clears all the bits of the bit array.\n*/\n\nvoid setAllBits(BitArray **bitArr);\n/*\n  Sets all the bits of the bit array.\n*/\n\nint equivalentDecimal(BitArray **bitArr);\n/*\n  Returns an equivalent decimal to the bit array.\n*/\nCheck main.c file for usage.\n\n###### Feel free to contribute and open any issues.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubhash3%2Fbit-arrays-in-c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsubhash3%2Fbit-arrays-in-c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubhash3%2Fbit-arrays-in-c/lists"}