In main()
(which should return an int
, btw), change this:
if (h[i][j]='1');
To this:
if (h[i][j]=='1')
for hopefully obvious reasons.
Next, your lookup array is not being initialized after allocation (and though you may not think it need be, it is required for the next error fix after this to work):
Change this:
unsigned long long *lookup = (unsigned long long*) malloc(N * sizeof(unsigned long long));
To this:
unsigned long long *lookup = calloc(N, sizeof(*lookup));
which will zero-fill the lookup array on inception. You could also memset
if you wanted to. The choice is yours.
And next, you're overwriting your lookup value for each row for multiple bits. I.e. the last bit you write into any row's lookup entry is the only one that is saved. You need to accumulate them using |=
rather than just =
. Also, you need to ensure the shift-operation is done on a ulonglong. As written it is shifting on an int
well-beyond the int
width. See below.
Change this:
lookup[i]=(1<<(63-j));
To this:
lookup[i]|=(((unsigned long long)1)<<(63-j));
Putting that all together and using a bit-printer I just slammed out, this is what I get:
1111111111111111111111111111111111111111111111111111111111111111
1010101010101010101010101010101010101010101010101010101010101010
1100110011001100110011001100110011001100110011001100110011001100
1001100110011001100110011001100110011001100110011001100110011001
1111000011110000111100001111000011110000111100001111000011110000
1010010110100101101001011010010110100101101001011010010110100101
1100001111000011110000111100001111000011110000111100001111000011
1001011010010110100101101001011010010110100101101001011010010110
1111111100000000111111110000000011111111000000001111111100000000
1010101001010101101010100101010110101010010101011010101001010101
1100110000110011110011000011001111001100001100111100110000110011
1001100101100110100110010110011010011001011001101001100101100110
1111000000001111111100000000111111110000000011111111000000001111
1010010101011010101001010101101010100101010110101010010101011010
1100001100111100110000110011110011000011001111001100001100111100
1001011001101001100101100110100110010110011010011001011001101001
1111111111111111000000000000000011111111111111110000000000000000
1010101010101010010101010101010110101010101010100101010101010101
1100110011001100001100110011001111001100110011000011001100110011
1001100110011001011001100110011010011001100110010110011001100110
1111000011110000000011110000111111110000111100000000111100001111
1010010110100101010110100101101010100101101001010101101001011010
1100001111000011001111000011110011000011110000110011110000111100
1001011010010110011010010110100110010110100101100110100101101001
1111111100000000000000001111111111111111000000000000000011111111
1010101001010101010101011010101010101010010101010101010110101010
1100110000110011001100111100110011001100001100110011001111001100
1001100101100110011001101001100110011001011001100110011010011001
1111000000001111000011111111000011110000000011110000111111110000
1010010101011010010110101010010110100101010110100101101010100101
1100001100111100001111001100001111000011001111000011110011000011
1001011001101001011010011001011010010110011010010110100110010110
1111111111111111111111111111111100000000000000000000000000000000
1010101010101010101010101010101001010101010101010101010101010101
1100110011001100110011001100110000110011001100110011001100110011
1001100110011001100110011001100101100110011001100110011001100110
1111000011110000111100001111000000001111000011110000111100001111
1010010110100101101001011010010101011010010110100101101001011010
1100001111000011110000111100001100111100001111000011110000111100
1001011010010110100101101001011001101001011010010110100101101001
1111111100000000111111110000000000000000111111110000000011111111
1010101001010101101010100101010101010101101010100101010110101010
1100110000110011110011000011001100110011110011000011001111001100
1001100101100110100110010110011001100110100110010110011010011001
1111000000001111111100000000111100001111111100000000111111110000
1010010101011010101001010101101001011010101001010101101010100101
1100001100111100110000110011110000111100110000110011110011000011
1001011001101001100101100110100101101001100101100110100110010110
1111111111111111000000000000000000000000000000001111111111111111
1010101010101010010101010101010101010101010101011010101010101010
1100110011001100001100110011001100110011001100111100110011001100
1001100110011001011001100110011001100110011001101001100110011001
1111000011110000000011110000111100001111000011111111000011110000
1010010110100101010110100101101001011010010110101010010110100101
1100001111000011001111000011110000111100001111001100001111000011
1001011010010110011010010110100101101001011010011001011010010110
1111111100000000000000001111111100000000111111111111111100000000
1010101001010101010101011010101001010101101010101010101001010101
1100110000110011001100111100110000110011110011001100110000110011
1001100101100110011001101001100101100110100110011001100101100110
1111000000001111000011111111000000001111111100001111000000001111
1010010101011010010110101010010101011010101001011010010101011010
1100001100111100001111001100001100111100110000111100001100111100
1001011001101001011010011001011001101001100101101001011001101001
Hopefully that is what its supposed to look like (honestly I haven't a clue).