This is the line of code that I am getting an error with.

mtx[cIndex(bitNum)] & = ~(1 << bIndex(bitNum));

The error code is:
expected primary-expression before â=â token

I think I am missing some '(' and ')''s. Thanks!

& = should be &=. Notice the whitespace.

Yep. That fixed it thank you.

mtx[cIndex(bitNum)] &= ~(1 << bIndex(bitNum));

is giving me a segmentation fault. Any ideas?

A segmentation fault happens when you try to access an invalid address. Typically that involves an uninitialized pointer, or an out of range index. My guess would be that cIndex(bitNum) is outside the bounds of your mtx array.

A segmentation fault happens when you try to access an invalid address. Typically that involves an uninitialized pointer, or an out of range index. My guess would be that cIndex(bitNum) is outside the bounds of your mtx array.

I had the size initialized wrong and that fixed it thank you very much. I am struggling with two more things and I should be done. The first is printing out my matrix which is a bit array.

for(int i=0; i < dim; i++)
   {
	for(int j=0; j < dim; j++)
   cout << mtx[i] << ' ';
   cout << endl;

That is the body of my print function. mtx is unsigned char array.

The next problem is when I switch my classes to use a lower triangular array. I have a functions that set all, which sets each element to 1, and clear all, which sets everything to 0. I looks like it is only setting the first element to 1. Here is my code that is having the problem.

for(int i=0; i < dim; i++)
	for(int j=0; j < dim; j++)
   mtx[i] = 0;

I appreciate the help.

This article has been dead for over six months. Start a new discussion instead.