pointer of pointer of a structure data type unexpected variation
Code:
Here is my problem: In the following code pcodewords is pointer of pointers of structure type. NodeConstruct, GetCodeWord and nextcw are functions with their own proper implementation. I am confused that eventhough the pointer pcodewords[0] is not affected by the do while loop, the printing results for its corrosponding structure variable before and after the do while loop are not the same.
I am really stacked because of this . I really need your help guys and it is urgent! 10q anyway!
pcodewords[0]=NodeConstruct(cw,n);
//printing values for checking
int *p=GetCodeWord(pcodewords[0]);
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);
pcodewords[0]=NodeConstruct(cw0,n);
//printing the values for checking
int *p=GetCodeWord(pcodewords[0]);
for(int j=0;j<n;j++)
printf("%d", *(p+j));
printf("\n");
}
Giving respect and thanks
Hello DWK, You really got my problem and gave me a proper solution. It means a lot for me . Anyway, 10q and Long life for you and yours!
BTW, could you suggest me an algorithm to use to implement the following problem with c:
eg. For n=6, number of ones(w)=3, the following binary words can be obtained in lexicographic order
000111
001011
001101
001110
010011
010101
010110
011001
011010
011100
100011
100101
100110
101001
101010
101100
110001
110010
110100
111000
What I want to do is to find all the possible solutions ,with maximum number of words, fulfilling
a minimum distance condition, eg d=3.
I am really stacked so plz forward me your suggestion asa possible 10q!