LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-28-2013, 03:43 AM   #1
niteen
Member
 
Registered: Mar 2013
Location: India
Distribution: Fedora
Posts: 61

Rep: Reputation: Disabled
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
 
Old 03-28-2013, 04:50 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
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...
 
Old 03-28-2013, 05:09 AM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,645

Rep: Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501
http://www.linuxquestions.org/questi...ng-4175455876/
 
Old 03-28-2013, 06:05 AM   #4
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Back to Debian, and only Debian.
Posts: 1,158
Blog Entries: 7

Rep: Reputation: 327Reputation: 327Reputation: 327Reputation: 327
Quote:
Originally Posted by acid_kewpie View Post
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...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to convert string to integer back to string C++ LazerPhreak Programming 1 03-13-2010 07:32 PM
Need help with a little bash script - generating unique folder names Shay Linux - Software 4 10-31-2008 10:07 PM
Generating 32-bit unique ID lucky6969b Programming 4 03-27-2006 08:59 AM
Bash Script- Finding/Generating unique UserIDs pheasand Linux - General 2 12-11-2004 09:44 AM
Integer To a String in C Bean101 Programming 2 05-27-2004 04:46 AM


All times are GMT -5. The time now is 08:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration