Can you please suggest an algorithm that uses pointers and I also have to read and save the text file, which I#m having trouble with. Here is a rough translation of the task into English(I used google translator so it's bit jumbled, my german's not that good):

Define a structure with two pointers to strings for each of the cities and the additional info. Set your internal memory for the data field with 100,000 array elements that are of this type of structure. Use the zip code as an index, for example, are stored in the array element with index [47 057] is a pointer to the string "Duisburg" and a null pointer for the addition or in the array element with index [45 472] is a pointer to the string "Mülheim" for the place and a pointer to the string "at the Ruhr for the addition. You needn't disk space, may be applied to places that are available with several postal codes, create their own strings for the name of the place and the additional info. The advantage of using such a field is that when you sort reading the data virtually to the zip code in time O (n) (this sorting method is called multiple distributors) and the search for data in super-fast constant time O (1) takes place.

You're going to have to show us that you have tried before you will get any help. What exactly are you struggling with? I'd suggest breaking it down into little pieces. At first, simple, short stand alone programs, which you then convert into function in your actual program.

1.
      bool found = false;
   2.
      int index = 0;
   3.
       
   4.
      cout << "Enter random zip code: ";
   5.
      cin >> zip_code;
   6.
       
   7.
      for(int i=0; i < max_number_of_cities; i++)
   8.
      {
   9.
      if(zip_code == mystruct[i].zip)
  10.
      {
  11.
      found = true;
  12.
      index = i;
  13.
      break;
  14.
      }
  15.
      }
  16.
       
  17.
      if(!found)
  18.
      {
  19.
      cout << "zip code not found in database.";
  20.
      }
  21.
      else
  22.
      {
  23.
      cout << "the zip code " << zip_code << " is for " << mystruct[index].city_name;
  24.
      }

This is what I'm workimg with so far, but I have trouble reading and saving the txt file, thanks

Comments
You idiot, you can't even cheat properly.

It looks to me like you have copied and pasted that code from another thread (the numbers in your text). This means you haven't compiled it. I also don't see a main() or the definition of mystruct.

>>search for data in super-fast constant time O (1) takes place.
This is pretty hard to accomplish, unless you have a hash table. So if this is a requirement, then you need to implement a hash table.

If you can do O(log n) you can use a sorted array, or use c++'s hash map.

DON'T use other people's code!

This article has been dead for over six months. Start a new discussion instead.