codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Character Array problem  lyndonp at 23:15 on Sunday, July 24, 2005
 

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.









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Re: Problem with concatenation
•  how to genrates the crystal report by sending a id at runtime
•  help me
•  pls help me with this..
•  Re: Security - Code verify
•  Job @ EarlySail
•  Job @ EarlySail (perl)
•  IPC problem
•  Re: import contacts of msn/yahoo


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007