Point me in the right direction

I just need someone to point me in the right direction to go for this. What I am attempting to do is to have the user input the file name in which they want to use, then the input will be formatted as such.

A	www.odu.edu 		192.012.174.002
A 	www.udonkey.com  	190.201.167.113
A	www.edce.com  		022.212.001.224
P
F	www.udonkey.com
F	www.turkeyTime.com
P
M	www.udonkey.com  	190.300.200.100
F	www.odu.edu
A 	www.myway.net		192.123.456.789
D	www.missin.org.
P
D  www.odu.edu
F	www.udonkey.com
Q
A 	www.noway.com		192.012.111.222



The first column represents a command. The second represents a domain name. The third is the ip address. I am supposed to store this info in an array of structs and then use the command from the input file to alter it as said.

Here are the exact guidelines.

----The infotype in this problem will consist of an Internet domain name (string), an IP number (string) and a counter (int). New entries are added to the end of the array. Whenever an item is accessed by the F(ind) or M(odify) command, its counter is incremented by one.----

These are the commands and what they do. I forgot to say this earlier. All of these commands have to be done with functions.

A (insert) will be followed by a domain name and IP number
A: Add an entry with the domain name, IP number, and zero counter to the end of the array
//----------------------------------------------------------------------------------------------------------------
M (modify) will be followed by a domain name and a new IP number
M: Changes the IP number for the indicated domain name. Increment the counter.
//----------------------------------------------------------------------------------------------------------------
D (delete ) will be followed by the name to delete from the array
D: deletes the entry with the indicated domain name from the array
//----------------------------------------------------------------------------------------------------------------
F (find) will be followed by a domain name to find in the list
F: print out the IP number for the indicated domain name. Increment the counter.
//----------------------------------------------------------------------------------------------------------------
P (print) will have no additional data
P: Print the contents of the array; print domain name, IP number, counter for each entry
//----------------------------------------------------------------------------------------------------------------
Q (quit) will have no additional data.
Q: stop processing; do the following:
Use Selection sort to sort the array in order by domain name.
Print the sorted list to the screen.
Prompt the user to input a top level domain ( for example edu ) Print a list of all list entries from that domain to the screen. (Allow multiple entries)
Print the list entry with the largest counter to the screen. (this was the most popular web site)
Print the sorted list to an output file.


This is about as far as I have gotten because I'm stuck at how to get this done.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>


using namespace std;

struct domList
{
string domName;
string ipAddress;
int counter;
};
    

int main (){
    
    char command;
    
    domList list[];
    
    string ipNum, domName;
    int counter = 0;

    ifstream dataFile;
    
    //stores the name of the dataFile
    string dataFile1;
    
    cout << "Please enter the data file you wish to use: ";
    cin >> dataFile1;
      
    dataFile.open (dataFile1);
    if (!dataFile) 
    {
       cout << "bummer file\n\n";
       system ("pause");
       return 1;
    }


I was planning on using a switch statement in order to use the commands but the biggest trouble that I am having is knowing how to actually use the commands. As in, they are not supposed to be stored in the array.
Last edited on
Topic archived. No new replies allowed.