Why scanf if this can be easily written by hand.
Up vote 0 down vote favorite share g+ share fb share tw.
(prefer 1 line with no loop) The solution I have in mind doesn't scale to 20+ hex string. Sscanf(input, "%x%x%x%x%x",output0, output1....output5); c sscanf link|improve this question asked Nov 19 '11 at 22:23Usavich1,438516 90% accept rate.
Sscanf(input, "%2x%2x%2x%2x%2x%2x",&output0, &output1, ..., &output5); – Krister Andersson Nov 19 '11 at 22:33.
Why scanf if this can be easily written by hand: const size_t numdigits = strlen(input) / 2; uint8_t * const output = malloc(numdigits); for (size_t I = 0; I! = numdigits; ++i) { outputi = 16 * toInt(input2*i) + toInt(intput2*i+1); } unsigned int toInt(char c) { if (c >= '0' && c = 'A' && c = 'a' && c.
The standard doesn't technically guarantee consecutive alphabet characters, but within the range A-F your code should work in EBCDIC on the two computers still using that. – Chris Lutz Nov 19 '11 at 22:32 @ChrisLutz: Indeed, there are a few assumptions there about the permissible encodings. Worst case you can replace the toInt body by a lookup table... – Kerrek SB Nov 19 '11 at 22:33.
Here is an alternate implementation. #include #include #define _base(x) ((x >= '0' && x = 'a' && x = 'A' && x > 1); for (p = input; p && *p; p+=2 ) { output(p - input) >> 1 = ((HEXOF(*p)).
If you do not want to use a loop, then you need to explicitly write out all six (or twenty) array locations (although %x is not the correct conversion character - it expects a pointer to unsigned int as its corresponding argument). If you don't want to write them all out, then you need to use a loop - it can be quite simple, though: for (i = 0; I.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.