I have set of zeroes and ones as my input like below, I need to do some pairwise Boolean operation (and, or, Xor, not) between them (consider each line as).
111100000000
101100000010
111011100000
111100000001
001100010001
The code for reading and storing each line is:
int lineCounter = 0;
while (std::getline(infile, line))
{
myinput[lineCounter] = bitset<LEN> (std::string(line));
lineCounter++;
}
Right now I am using array of bitset to store each line bitset<LEN> myinput[NUMBER];
that LEN
is size of each line and NUMBER
is number of lines in my input file. But the problem is I don't want to specify LEN
and NUMBER
during compile time since I have to work with different input. having said that I want user give the LEN
and NUMBER
as an input argument when running the program. Since I can not do dynamic allocation for bitset I want to use vector but don't know how should I use it to fulfill my job!
can you please tell how can read and store my input and do pairwise boolean operation with help of vector or anything else that can handle dynamic allocation.