Test

2017-05-16 12:26:11 UTC

I have

...

char str[4];

..

where number up to 9999 where stored as in:

strcpy(str,"9999");

The original design was that only 0-9999 would be enough (only positive

integers). Unfortunately this was not enough (after 10 years). It would much

better if I could fit a higher number. What I need to maintain compatibility, ie

if str gets " 15" it mean number 15. A hex number could otherwise suffice if not

for compatibility.

A quick solution would have a numbering systems where 0..9998,9999, AAAA,AAAB...

etc. where "AAAA" is 10000 and "AAAb" 10001 and so on.

Another oen could be using a hex number say "1000" is 4096 decimal.

This would make life a lot easier and provide backward comptibility: older

systems can continue providing 0...9999 but newer systems would be able to also

utilize higher numbers while haveing 0...9999 if the number is within oldstyle

range. When when the main program sees anything other than space of a digit it

assumes that a newer version want to give a number larger than 9999.

Not wanting to reinvent the wheel are there C source code examples to this

effect?

...

char str[4];

..

where number up to 9999 where stored as in:

strcpy(str,"9999");

The original design was that only 0-9999 would be enough (only positive

integers). Unfortunately this was not enough (after 10 years). It would much

better if I could fit a higher number. What I need to maintain compatibility, ie

if str gets " 15" it mean number 15. A hex number could otherwise suffice if not

for compatibility.

A quick solution would have a numbering systems where 0..9998,9999, AAAA,AAAB...

etc. where "AAAA" is 10000 and "AAAb" 10001 and so on.

Another oen could be using a hex number say "1000" is 4096 decimal.

This would make life a lot easier and provide backward comptibility: older

systems can continue providing 0...9999 but newer systems would be able to also

utilize higher numbers while haveing 0...9999 if the number is within oldstyle

range. When when the main program sees anything other than space of a digit it

assumes that a newer version want to give a number larger than 9999.

Not wanting to reinvent the wheel are there C source code examples to this

effect?