Mercurial > hg > Members > masakoha > testcode
view regexParser/bitVector.cc @ 275:8879eb8c64a8
remove segmentation fault
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 30 Jan 2016 19:06:41 +0900 |
parents | 02031fb73af8 |
children |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "regexParser.h" BitVector createBitVector(int state) { unsigned long tmp = 1 << state; BitVector bi1 = (BitVector){.bitContainer = tmp}; return bi1; } BitVector bitSet(BitVector bi, int bitSetPosition) { unsigned long tmp = 1 << bitSetPosition; BitVector bi1 = (BitVector){.bitContainer = bi.bitContainer | tmp}; return bi1; } void bitPrint(BitVector bi) { unsigned long vec = bi.bitContainer; for (int j = 0; j < BITBLOCK; j++) { putchar((vec & 1) ? '1':'0'); vec >>= 1; } printf("\n"); }