c data types help needed for project

This is a discussion on c data types help needed for project within the C Programming forums, part of the General Programming Boards category; i have a coding assignment to mimic hash functions in c. where i hav to store student id, name ,telephone ...

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    2

    c data types help needed for project

    i have a coding assignment to mimic hash functions in c. where i hav to store student id, name ,telephone no. and hash it by telephone no. say telephone no. is 9828689999 .
    i m using gcc , long int is overflowing and modulo operation is coming to b not defined on double( giving err- invalid operands to binary %)

    kindly help me in choosing data type for telephone no.

    thanks in advance.

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    I believe a telephone number should be represented as a string. After all you wouldn't expect arithmetic to make much sense for them.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    Why not use a string?

  4. #4
    Registered User
    Join Date
    Sep 2008
    Posts
    2
    sry but i need to do 9828683961%41 which may not work for string (as per my knowledge)

  5. #5
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    Why do you need to do that?

  6. #6
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Well let me address some quick things you probably have not really put a lot of thought into:

    1. Country codes
    2. Extentions

    Since you are obviously keeping area and region codes in mind with whatever hashing algorithm you are trying to devise.

    The problem with using a phone number for a hash is that a phone number is not unique to an individual. Unless you have designed your database or whatever to use it as some sort of key.. But even then I would recommend a different identifier as a key.

    [edit]Long story short, just use a string.[/edit]

  7. #7
    Registered User
    Join Date
    Apr 2006
    Posts
    2,050
    Or you could write your own class for it.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bitmasking Problem
    By mike_g in forum C++ Programming
    Replies: 13
    Last Post: 11-07-2007, 11:24 PM
  2. Extending basic data types.
    By nempo in forum C++ Programming
    Replies: 23
    Last Post: 09-25-2007, 03:28 PM
  3. C data types
    By dbaryl in forum C Programming
    Replies: 3
    Last Post: 07-21-2002, 01:05 AM
  4. Data types in Unicode
    By Garfield in forum Windows Programming
    Replies: 12
    Last Post: 10-28-2001, 09:48 AM
  5. Need help with simple data types
    By partnole in forum C++ Programming
    Replies: 1
    Last Post: 10-03-2001, 08:36 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21