- Look for the right source of information without too much help
- How to manipulate bits and use bitwise operators
-
0. 0
- 0-binary_to_uint.c: C program that converts a binary number to an
unsigned int
- Prototype:
unsigned int binary_to_uint(const char *b);
- where
b
is pointing to a string of0
and1
chars - Return: the converted number, or 0 if
- there is one or more chars in the string
b
that is not0
or1
b
isNULL
- there is one or more chars in the string
- Prototype:
- 0-binary_to_uint.c: C program that converts a binary number to an
-
1. 1
- 1-print_binary.c: C program that prints the binary representation of a number
- Prototype:
void print_binary(unsigned long int n);
- arrays are not allowed
malloc
is not allowed%
or/
operators are not allowed
- Prototype:
- 1-print_binary.c: C program that prints the binary representation of a number
-
2. 10
- 2-get_bit.c: C program that returns the value of a bit at a given index
- Prototype:
int get_bit(unsigned long int n, unsigned int index);
- where
index
is the index, starting from0
of the bit you want to get - Return: the value of the bit at index
index
or-1
if an error occurred
- Prototype:
- 2-get_bit.c: C program that returns the value of a bit at a given index
-
3. 11
- 3-set_bit.c: C program that sets the value of a bit to
1
at a given index- Prototype:
int set_bit(unsigned long int *n, unsigned int index);
- where
index
is the index, starting from0
of the bit you want to set - Return:
1
if it worked, or-1
if an error occurred
- Prototype:
- 3-set_bit.c: C program that sets the value of a bit to
-
4. 100
- 4-clear_bit.c: C program that sets the value of a bit to
0
at a given index- Prototype:
int clear_bit(unsigned int *n, unsigned int index);
- where
index
is the index, starting from0
of the bit you want to set - Return:
1
if it worked, or-1
if an error occurred
- Prototype:
- 4-clear_bit.c: C program that sets the value of a bit to
-
5. 101
- 5-flip_bits.c: C program that returns the number of bits you would need to flip to get from one number to another.
- Prototype:
unsigned int flip_bits(unsigned long int n, unsigned long int m);
%
or/
operators are not allowed
- Prototype:
- 5-flip_bits.c: C program that returns the number of bits you would need to flip to get from one number to another.
-
6. Endianness
- 100-get_endianness.c: C program that checks the endianness
- Prototype:
int get_endianness(void);
- Return:
0
if big endian,1
if little endian
- Prototype:
- 100-get_endianness.c: C program that checks the endianness
-
7. Crackme3
- 101-password: Password to task 7