arrays and structs

i cant get the voids and the output file to work...it wont recognize anything i put in the parenthesis
this is due by midnight tonight and im freaking out
i am using bloodshed dev c++ compiler
please help








#include <iostream>
#include <string>
#include <istream>
#include <fstream>
#include <cstdlib>
#include<iomanip>

using namespace std;

#define MAX_ENTRIES 50



struct internet
{
string internetDomain;
string ipNumber;
int counter;
};

// declare the array of structs - Need to determine if this is dynamically allocated or not.
struct internet *list[MAX_ENTRIES];


void selectionSort();
void insertEntry(string, string);
void removeEntry(string);
void findAndIncrementEntry(string);
void printEntries();
void finishAndExit();
void modifyIP(string, string);
int arrayIndex(string);
void printEntriesNotVisited();
void printEntriesVisitedMost();
void OutputFile(std:: ofstream& outVariable, internet list[], int listSize);



int main()
{

ifstream inFile;
ifstream OutputFile;
string fileName;
string domainName;
string ipAddress;
int ARRAY_SIZE=50;

//array name
internet location[ARRAY_SIZE];



// Prompt the user to enter the input filename
cout << "Enter the filename:";
cin >> fileName;

// Open the file name entered.
inFile.open(fileName.c_str());

// Loop through the file and do the actions that it does until you get to the X instruction or end of file.
if( inFile.is_open())
{
while(! inFile.eof() )
{
char action;

// Get the line
inFile >> action;

// Now perform the action specified by the file.
switch(action)
{
case 'X':
finishAndExit();
break;
case 'M':
inFile >> domainName;
inFile >> ipAddress;
modifyIP(domainName,ipAddress);
break;
case 'I':
inFile >> domainName;
inFile >> ipAddress;
insertEntry(domainName,ipAddress);
break;
case 'R':
inFile >> domainName;
removeEntry(domainName);
break;
case 'F':
inFile >> domainName;
findAndIncrementEntry(domainName);
break;
case 'P':
printEntries();
break;
}
}
} else {
cout << "File " << fileName << " not found";

}
}
int ARRAY_SIZE=50;

OutputFile (internet, ARRAY_SIZE);

//Close input and output files
inFile.close();
OutputFile.close();
}

void finishAndExit() {
string test;
// Sort the intems in the array using the selectionSort
selectionSort();
// Print the sorted entries
printEntries();

// Print the entries with a zero counter
printEntriesNotVisited();

// Print the entry with the largest
printEntriesVisitedMost();

// Write output to file.
OutputFile();

exit(0);
}

void modifyIP(string domainName, string ipAddress) {

// Look for the item that is being changed and then update it accordingly
int entryIndex = arrayIndex(domainName);
if(entryIndex != -1) {
list[entryIndex]->ipNumber = ipAddress;
}
return;
}

void insertEntry(string domainName, string ipAddress) {

cout << "Adding " << domainName << endl;
// Need to create the space for the entry and update the structures data elements.
for(int i=0;i < MAX_ENTRIES; i++) {
if(list[i] == NULL ) {
list[i] = new internet();
list[i]->internetDomain = domainName;
list[i]->ipNumber = ipAddress;
list[i]->counter = 0;
return;
}
}
}


void removeEntry(string domainName) {

cout << "Removing " << domainName << endl;

int entryIndex = arrayIndex(domainName);
if(entryIndex != -1) {
delete list[entryIndex];
list[entryIndex]=NULL;
}

}

void findAndIncrementEntry(string domainName) {

cout << "Finding " << domainName << endl;

int entryIndex = arrayIndex(domainName);
if(entryIndex != -1) {
list[entryIndex]->counter++;
}

}

void printEntries() {

cout << "Printing Entries: " << endl;
sizeof(list);
for(int i=0; i < MAX_ENTRIES ; i++) {
if(list[i] != NULL && list[i]->internetDomain != "") {
cout << "Domain:" << list[i]->internetDomain << " IP:" << list[i]->ipNumber << " Count: " << list[i]->counter << endl;
}
}

}

void printEntriesNotVisited() {

cout << "Entries not visited: " << endl;
sizeof(list);
for(int i=0; i < MAX_ENTRIES ; i++) {
if(list[i] != NULL && list[i]->internetDomain != "") {
if(list[i]->counter == 0) {
cout << "Domain:" << list[i]->internetDomain << " IP:" << list[i]->ipNumber << " Count: " << list[i]->counter << endl;
}
}
}

}

void printEntriesVisitedMost() {

int maxCount = 0;
int maxCountIndex;


for(int i=0; i < MAX_ENTRIES ; i++) {
if(list[i] != NULL && list[i]->internetDomain != "") {
if(maxCount < list[i]->counter) {
maxCount = list[i]->counter;
}
}
}

cout << "Most popular Sites: " << endl;
for(int i=0; i < MAX_ENTRIES ; i++) {
if(list[i] != NULL && list[i]->internetDomain != "") {
if(maxCount == list[i]->counter) {
cout << "Domain:" << list[i]->internetDomain << " IP:" << list[i]->ipNumber << " Count: " << list[i]->counter << endl;
}
}
}

}


int arrayIndex(string domainName) {

for(int i=0; i < MAX_ENTRIES ; i++) {
if(list[i] != NULL && list[i]->internetDomain == domainName) {
return i;
}
}

// Can't find the specific domain.
return -1;

}


// This will need to be modified to accept the internet structs array
void selectionSort()
{
int index;
int smallestIndex;
int minIndex;
struct internet *temp;
for (index = 0; index < MAX_ENTRIES - 1; index++)
{
if(list[index] == NULL)
continue;
//Step a
smallestIndex = index;
for (minIndex = index + 1; minIndex < MAX_ENTRIES; minIndex++) {
if(list[minIndex] == NULL) {
continue;
}
if (list[minIndex]->internetDomain.compare(list[smallestIndex]->internetDomain) < 0)
smallestIndex = minIndex;
//Step b
}
temp = list[smallestIndex];
list[smallestIndex] = list[index];
list[index] = temp;
}
}

void OutputFile(ofstream& outVariable, internet list[], int listSize)
{

//Outputs header of list
outVariable << setw(30) << left << "Internet domains"
<< "Number observed\n\n";

//Loops through array and outputs list of 2 columns: species and count
for (int counter = 0; counter< listSize; counter++)
{
if (list[counter].internetDomain != "")//If sturct is not null
{
outVariable << setw(30) << left << list[counter].internetDomain << " "
<< setw(3) << right << list[counter].counter << "\n";
}
}
}//End outputData


ok now that works but the counter will not count correctly
im get this as an output




Enter the filename:one.txt
Adding www.odu.edu
Adding www.udonkey.com
Adding www.edice.com
Adding www.cnn.com
Adding www.facespace.co.uk
Adding www.myspaces.com
Adding www.groogle.com
Adding www.myspacing.com
Adding www.gatormeat.com
Adding www.ewomen.org
Adding www.uharmony.com
Adding www.dogsteaks.com
Adding www.curling.org
Adding www.mousehouse.tv
Adding www.facespaces.com
Printing Entries:
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Domain:www.odu.edu IP:192.012.174.002 Count: 0
Finding www.gatormeat.com
Press any key to continue . . .




the files that i am using can be found at this link and they are .txt files
http://www.cs.odu.edu/~cs150/projects/project_4/
Topic archived. No new replies allowed.