خرید بک لینک

Vote count: 0

I have a program that takes 2x24bit integer converts them to strings via sprintf and put them together to a string that represents a 58bit number. Program:

int buffer_h = 0x001FFFFF;

int buffer_l = 0x002FFFFF;

int i,j = 0;

char res_h[10];

char res_l[10];

char res_all[12];

sprintf(res_h,"%06X",buffer_h);

sprintf(res_l,"%06X",buffer_l);

for(i=0;i<6;i++){

res_all[i] = res_h[i];

}

for(i=0;i<6;i++){

res_all[i+6] = res_l[i];

}

printf("%s",res_all);

You maybe think the output on res_all is res_h+res_l which are 6+6=12 characters so: 1FFFFF2FFFFF but the output is: 1FFFFF2FFFFF2FFFFF if I shorten res_all to res_all[6] it's all right

but how can a 6 character string be printed to a 18 character?

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 16 فروردين 1395 ساعت: 2:14

صفحه بندی