I have created a simple program to generate and store all combinations of numbers (up to 8 i this example) in binary in an array. However when i try and run the script the error message Segmentation Fault:11 appears. I can't figure out what is wrong..
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
int main()
{
int no,i=0,j;
int *d;
d = (int *)malloc(sizeof(int)*50);
for(no=0;no<8;no+=1)
{
do
{
d[i]=no%2;
i++;
no=no/2;
}while(no>0);
}
for(j=i-1;j>=0;j--)
{
printf("%d",d[j]);
}
}