This is really helpful! Thanks :)

See I'm confused! What do I need to do?

This is the header file;

[CODE]#include

using std::string;

struct CarC
{
string carRegistration;
string carOwner;
string ownerAddress;
string carManufacturer;
string carModel;
unsigned numCarDoors;
unsigned numCarSeats;
string carType;
string carInformation;
};

struct BusB
{
string busRegistration;
string busOwner;
string ownerAddress;
string busManufacturer;
string busModel;
string busColour;
unsigned numBusAxles;
unsigned numBusPassengers;
string busBodyType;
string busInformation;

};

struct LorryL
{
string lorryRegistration;
string lorryOwner;
string ownerAddress;
string lorryManufacturer;
string lorryModel;
string lorryColour;
unsigned numLorryAxels;
string lorryBodyType;
string lorryInformation;
};

struct MotorbikeM
{
string motorbikeRegistration;
string motorbikeOwner;
string ownerAddress;
string motorbikeManufacturer;
string motorbikeModel;
string motorbikeColour;
string motorbikeSideCar;
string motorbikeInformation;
};[/CODE]

and I created this to put the information in;

[CODE]<?xml version="1.0" encoding="utf-8"?>

[/CODE] Is that what you mean?

Yes, sorry! All of the code is below. When I run the program it says "File to open", I've tried typing in files I've made e.g "Cars.txt", or just "Cars", I've tried entering existing files, but it always comes up with "error with tag", so what do I need to write?

[CODE]#include "stdafx.h"

include
include
include
include "Vehicles.h"

using namespace std;
const unsigned MAX_VEHICLES = 10;

//4 routines to create & populate various aircraft from csv string
CarC buildC(string dataLine);
BusB
buildB(string dataLine);
LorryL buildL(string dataLine);
MotorbikeM
buildM(string dataLine);

//4 routines to display various aircraft on std::cout
void displayC(CarC cPtr);
void displayB(BusB
bPtr);
void displayL(LorryL lPtr);
void displayM(MotorbikeM
mPtr);

string extractLastString(string & st);
int extractLastInt(string & st);

int _tmain(int argc, _TCHAR argv[])
{
char tags[MAX_VEHICLES];
void
vehicles[MAX_VEHICLES];

ifstream infile;
if (argc >1)
{
    //filename passed as command line argument
    //set in Project->Properties->Configuration->Debugging
    infile.open(argv[1]);
}
else 
{
    string fileName;
    cout << "File to open" << endl;
    cin >> fileName;
    infile.open(fileName.c_str());
}
int c = 0;
string inputLine;
while (!infile.eof() && (c< MAX_VEHICLES))
{
    getline(infile, inputLine);
    tags[c] = inputLine[0];
    switch (tags[c])
    {
        case 'C': vehicles[c] = buildC(inputLine); break;
        case 'B': vehicles[c] = buildB(inputLine); break;
        case 'L': vehicles[c] = buildL(inputLine); break;
        case 'M': vehicles[c] = buildM(inputLine); break;
        default: cout << "error with tag " << endl;break;
    }
    ++c;
}
unsigned numVehicles = c;
for (int i=0; i<numVehicles; ++i)
{
    switch (tags[i])
    {
        case 'C': displayC((CarC*) vehicles[i]); break;
        case 'B': displayB((BusB*) vehicles[i]); break;
        case 'L': displayL((LorryL*) vehicles[i]); break;
        case 'M': ...
lauw0203 Newbie Poster

Hello :)

I'm creating a license plate recognition system for my coursework at University. We need to use Binary trees, which I've done but the information needs to be stored in a file to read and write to. I've created some text files with XML tags in for Cars, Lorries, Buses and Motorbikes and I've written some of the code below, but the "File to open" bit my tutor helped me with. When I run the program, it says "File to open" and I'm not sure what I need to do? Would anyone be able to help me?

[CODE]int _tmain(int argc, _TCHAR argv[])
{
char tags[MAX_VEHICLES];
void
vehicles[MAX_VEHICLES];

ifstream infile;
if (argc >1)
{
    //filename passed as command line argument
    //set in Project->Properties->Configuration->Debugging
    infile.open(argv[1]);
}
else 
{
    string fileName;
    cout << "File to open" << endl;
    cin >> fileName;
    infile.open(fileName.c_str());
}
int c = 0;
string inputLine;
while (!infile.eof() && (c< MAX_VEHICLES))
{
    getline(infile, inputLine);
    tags[c] = inputLine[0];
    switch (tags[c])
    {
        case 'C': vehicles[c] = buildC(inputLine); break;
        case 'B': vehicles[c] = buildB(inputLine); break;
        case 'L': vehicles[c] = buildL(inputLine); break;
        case 'M': vehicles[c] = buildM(inputLine); break;
        default: cout << "error with tag " << endl;break;
    }
    ++c;
}[/CODE]

Thanks :)

No worries, I've took it out of Gwin. Don't even need to use it! Thanks if you went to help lol xx

lauw0203 Newbie Poster

Hello :)

I'm having a couple of errors that i just can't get my head around so please help!

[U]Error 1[/U]

[B]warning C4018: '<' : signed/unsigned mismatch[/B]

[CODE] for (int i=0; i<numVehicles; ++i)
[/CODE]

[U]Error 2[/U]

[B]error LNK2019: unresolved external symbol _main referenced in function "int __cdecl console_main(int,char const)" (?console_main@@YAHHQAPAD@Z)[/B]

[CODE]int _tmain(int argc, _TCHAR* argv[])
{
GWindow Gwin;

// Clear the Gwin window
Gwin.clear();

Gwin.setPenColour(BLACK);

char tags[MAX_VEHICLES];
void * vehicles[MAX_VEHICLES];

ifstream infile;
if (argc >1)
{
    //filename passed as command line argument
    //set in Project->Properties->Configuration->Debugging
    infile.open(argv[1]);
}
else 
{
    string fileName;
    cout << "File to open" << endl;
    cin >> fileName;
    infile.open(fileName.c_str());
}[/CODE]

Thanks!