c - PBC element_to_bytes error "prints garbage" Unable to convert element to string -
i getting garbage values when convert element_t string. reason?
element_printf("element_a: %b",a); //int len = element_length_in_bytes(a); unsigned char* stra= (unsigned char*)malloc(element_length_in_bytes(a)*sizeof(char)); element_to_bytes(stra,a); printf("\n\n\n a: %s\n\n\n",stra);
the output is:
element_a: 676879270129030191324293305775237511254264666883 a: v�p��?�p�+��a�����[
i want normal print element_a. missing?
thanks, yogesh
you not getting garbage , not converting element string. passing array of bytes printf , tell function interpret them characters. no surprise not work. try element_snprint()
element_printf("element_a: %b",a); size_t s = (size_t) element_length_in_bytes(a); char* stra= (char*)malloc(s*sizeof(char)); element_snprint(stra, s, a) printf("\n\n\n a: %s\n\n\n",stra);
Comments
Post a Comment