I discovered the static keyword

This commit is contained in:
Marc
2022-10-04 16:25:44 +02:00
parent c276e18282
commit f8c5020a87
9 changed files with 61 additions and 58 deletions
+7 -7
View File
@@ -8,13 +8,13 @@
#include <glib.h>
#include "file.h"
u_int32_t countSetBits(u_int32_t n) {
// base case
if (n == 0)
return 0;
else
// if last bit set add 1 else add 0
return (n & 1) + countSetBits(n >> 1);
static u_int32_t countSetBits(u_int32_t n) {
// base case
if (n == 0)
return 0;
else
// if last bit set add 1 else add 0
return (n & 1) + countSetBits(n >> 1);
}
//TODO: add interruption support