[How] Write simple hash function

How to construct a simple hash function ? When the program executes, it will ask for your name. Type your name and it will print out a "hash code" (a number) from that name.
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <functional>

int main()
{
    std::string name ;
    std::cout << "name? " ;
    std::getline( std::cin, name ) ;
    std::hash<std::string> hash ;
    std::cout << "name: " << name << "    hash code: " << hash(name) << '\n' ;
}

http://ideone.com/TQJA03
Topic archived. No new replies allowed.