So if I have "www.google.it", "74.125.225.127", and "www.microsoft.com", "64.4.11.42", and 8 other in a String called 'fact'. How do I create a code that will hash this and when the user input google.com, the program will output the numbers?
So, hashing? first of all, with witch algorithm of hashing do you want to make it hash? MD4? MD5? etc. ?
OR with an algorithm by yourself?
after making the algorithm of hashing other part of program is so easy.
as the LowestOne said you should use map, but before it you should hash them with your algorithm, then as the LowestOne said take them to the map and now you can use them.
I think i can't understand your question. if its true :( sorry :S
Have Nice Life
In addition to what the lowestOne suggested, you can also try std::unordered_map which actually hashes the values to provide O(1) queries.
std::map uses a red_black tree internally to store values and so queries are closer to O(lgN) than O(1) (This is in the worst case ofc, so choose wisely)
One obvious problem is that your data has quotes around it. When you enter the URL are you entering it with quotes? Can you remove the quotes from the data file? Otherwise I would suggest removing the quotes when you read in the data.
After the second getline, the infile buffer is going to contain a '\n'. That is going to terminate subsequent reads so you will get only the first pair in your map. You need to use the following in order to skip the '\n'.
infile.ignore (1000, '\n');
PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/