LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   generating unique integer from string (https://www.linuxquestions.org/questions/linux-newbie-8/generating-unique-integer-from-string-4175455882/)

niteen 03-28-2013 03:43 AM

generating unique integer from string
 
i am currently working on gcc compiler for c language.
i am having 8 Digit unique string and need to generate integer ranging 0 to 64.
using gcc.
Any idea would be very helpfull,thanks

acid_kewpie 03-28-2013 04:50 AM

there are plenty of hashing algorithms out there, this reads an awful lot like homework thoguh, so i'm not going to link to anything you shoudl really be researching yourself. Generally you'd probably want to look at converting the string into a long number and then performing a modulus of that number to get a number in the range you want. Of course, a number between 1 and 64 can only be so unique...

pan64 03-28-2013 05:09 AM

http://www.linuxquestions.org/questi...ng-4175455876/

goumba 03-28-2013 06:05 AM

Quote:

Originally Posted by acid_kewpie (Post 4920402)
Of course, a number between 1 and 64 can only be so unique...

Of someone misread their homework and it's supposed to be an integer of a certain size... which would make sense from a 8 digit (i take this to mean 8 characters) string...


All times are GMT -5. The time now is 05:09 AM.