Name: Anonymous 2007-11-09 13:44
I need to store a value fit for an unsigned long long but i'm unsure wheather to use an actualy ull or a char array for it.
See this is all done by parsing encoded data, so when i encounted this value it will be in text form and i would have to use strtoull for conversion and storage.
This is all good and well, probably what i should do, if it wasn't for the second stage of my program.
You see later on i need to be able to process all the stored data i've parsed and recreate the encoded data it was parsed from. To do this with the ull value i would have to convert it back to a string.
So basically my question here is, should i use a ull value and make one end of the program simpler or should i put it in a string from the start and make the other end of the program simpler. Because if i don't use a char array to store it then i will have to figure out how to convert a ull value to a char array.
I have a function to convert integers to char arrays but it isn't mine, anyone who has read k&r will recognize it. To be honest it's kinda over my head, so writing one that supports ull would be a too difficult challenge for me.
Also, nothing i can see in the itoa function speaks against the fact that it can be converted to support ull simply by changing the argument definition, amirite or completely wrong?
I think writing this post helped me decide, i'll just go with storing it in a char array until i know more about converting ull to char **. I'll post this anyways just to spark discussion, also lispfags.
See this is all done by parsing encoded data, so when i encounted this value it will be in text form and i would have to use strtoull for conversion and storage.
This is all good and well, probably what i should do, if it wasn't for the second stage of my program.
You see later on i need to be able to process all the stored data i've parsed and recreate the encoded data it was parsed from. To do this with the ull value i would have to convert it back to a string.
So basically my question here is, should i use a ull value and make one end of the program simpler or should i put it in a string from the start and make the other end of the program simpler. Because if i don't use a char array to store it then i will have to figure out how to convert a ull value to a char array.
I have a function to convert integers to char arrays but it isn't mine, anyone who has read k&r will recognize it. To be honest it's kinda over my head, so writing one that supports ull would be a too difficult challenge for me.
Also, nothing i can see in the itoa function speaks against the fact that it can be converted to support ull simply by changing the argument definition, amirite or completely wrong?
void itoa(int n, char s[]) { /* K&R */
int i, sign;
if((sign = n) < 0) {
n = -n;
}
i = 0;
do {
s[i++] = n%10+'0';
} while((n /= 10) > 0);
if(sign < 0) {
s[i++] = '-';
}
s[i] = '\0';
reverse(s);
}I think writing this post helped me decide, i'll just go with storing it in a char array until i know more about converting ull to char **. I'll post this anyways just to spark discussion, also lispfags.