I am not an expert C/C++ programmer, and am having a bit of a problem on a school assignment. The assignment is to build a text file based database. The program has to read a schema file containing information about the individual tables (table name, filename, data field name, type, and length). Then it must be able to read the data files and do operations on the tables.
A line from the schema file looks like this (it may wrap):
customer,customer.txt,customer_name,C,15,customer_street,C,15,customer_city,C,15:
A comma seperates the information and a colon terminates the line.
I created two structs that will hold the common data and also up to 10 sets of column data. The structs are shown below.
// Create a struct for the data elements
struct dataField
{
char fieldName[15];
char fieldType[1];
char fieldLen[2];
};
// Create class for a line describing one table schema limited to 10 data elements
struct schema
{
char tableName[15];
char fileName[15];
int fieldsUsed;
dataField data[10];
};
Without posting a large amount of code, I can get the text file read in and display the contents of the individual dataField element (such as fieldName) right after I load them. However, when I try to read the individual dataField.fieldName element any time after loading the next element, I get run together data like
customer_name C15customer_streetC15customer_city C15
Any ideas on why it doesn't seem to give me just the data I loaded? I am using a Microsoft VC++ environment to write a command line program.
Thanks.