I am new that is why i am not in the right track of presentation! Here is a clear code

Code:

#include<stdlib.h>
#include "node.h"
#include "functions.h"
int main()
{
int n,d,w;
//inputs from user
printf("Enter n,d,and w:\nn=");
scanf("%d",&n);
printf("d=");
scanf("%d",&d);
printf("w=");
scanf("%d",&w);
printf("n=%d, d=%d, w=%d\n",n,d,w);
//generate the codewords
Node **pcodewords;
pcodewords=malloc(sizeof *pcodewords);
pcodewords[0]=NULL;
int cw[n],cw0[n];
//The initial codeword is 00000....111111
for(int i=0;i<n-w;++i)
cw[i]=cw0[i]=0;
for(int i=n-w;i<n;++i)
cw[i]=cw0[i]=1;
pcodewords[0]=NodeConstruct(cw,n);
/printing the codewords for checking
for(int i=0;i<combination(n,w);i++)
{
int *p=GetCodeWord(pcodewords[i]);
for(int j=0;j<n;j++)
printf("%d", *(p+j));
printf("\n");
}
int *cexist,i=1;
do
{
cexist=nextcw(cw,n);
if(cexist)
pcodewords[i]=NodeConstruct(cexist,n);
++i;
}while(cexist);
//printing the codewords for checking
for(int i=0;i<combination(n,w);i++)
{
int *p=GetCodeWord(pcodewords[i]);
for(int j=0;j<n;j++)
printf("%d", *(p+j));
printf("\n");
}
}

**The following are the node.h and functions.h header files. if needed i can come up with their implementation**

Code:

#ifndef NODE_H
#define NODE_H
typedef struct NodeStruct Node;
Node* NodeConstruct( int *cw,int n);
void NodeDestruct(Node *);
int* GetCodeWord(Node *);
int GetCsize(Node *n);
void SetCsize(Node *n, int a);
int Getd(Node *, Node *,int);
void SetChildNodes(Node *, Node **, int);
Node **GetChildNodes(Node *n);
#endif
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
int *nextcw(int cw[], int n);
int combination(int n, int w);
#endif

I did check for different values of n and w. I couldn't get the same answer all the time. eg. for n=6 and w=3. I am waiting for a solution.