Can anyone please explain what's wrong? am just getting Segmentation fault. am using "gcc code.c -o code -lm" to compile it.
#include <math.h>
#include <stdio.h>
typedef unsigned int unsint;
const char* secret="E...EA...WSC..OP.S.EE.SSA.C....A";
void funca(unsint* a, unsint b) {*a^=b;}
int main() {
unsint *a = 0;
for (int counter=0;counter<=31;counter++) {
char charec=secret[counter];
long lnum=counter==0?1:pow(2,counter);
charec==46?funca(a,lnum):NULL;
}
printf("\nresult: %u\n",a);
return 0;
}
secret
? And how many elements you are trying to index in the loop? – Eugene Sh. Feb 8 '17 at 21:08secret
has 26 characters in it, but you iterate through 31. – chrisaycock Feb 8 '17 at 21:08secret
is defined above, and is surprisingly ... too short. – Jean-François Fabre♦ Feb 8 '17 at 21:08