How to write a program to modify a word using a bit mask ?

#include <stdio.h> int main() { typedef int bool; bool f; /* conditional flag */ unsigned int m; /* the bit mask */ unsigned int w; /* the word to modify: if (f) w |= m; else w &= ~m; */ printf(“Enter the word to modify “); scanf(“%u”,&w); printf(“Enter the bit mask “); scanf(“%u”,&m); /* w …

Hacking the program for counting bits set

$gcc counting-bits-set-naive-way-related.c $./a.out Enter v 8474578 Total bits set in v is 11 $./a.out Enter v 1 Total bits set in v is 1 $./a.out Enter v 2 Total bits set in v is 1 $./a.out 3 Enter v a Total bits set in v is 0 $cat counting-bits-set-naive-way-related.c #include <stdio.h> int main() { unsigned …

Hacking with a program which has initialization of a MYSQL object

$ls connect1-p1.c $cp connect1-p1.c connect1-p2.c $emacs connect1-p2.c $gcc -lmysqlclient -g -L/usr/lib/mysql connect1-p2.c $./a.out mysql_init failed $echo $? 1 $./a.out 2> error.txt $cat error.txt mysql_init failed $emacs connect1-p2.c $gcc -lmysqlclient -g -L/usr/lib/mysql connect1-p2.c $./a.out mysql_init failed $./a.out 2> error.txt mysql_init failed $cat error.txt $