New programming student assistance

I'm new to the world of programming and have been assigned with the task of taking data from 2 separate input files and rewriting it to a xml file as output through my program. As for opening the files, that is not my issue. I have a csv file and a txt file that are as follows:

The csv file is a one line, comma delimited text tile with the following :
Bright, Rich, PC12K2RT, 10/21/2011

The txt file is fixed length text file with the following:
PC12K2RTUsed Car 02350.00

Now i have been educated to the point where i can successfully code a working c++ program that will open both files and enter both sets of data into a third output file as is. What I am suppose to do is for the csv file grab each set of data between the commas and save as different variables. And for the txt file grab each set of data following this parameter for a fixed file type (the numbers mean between which characters certain data is):

1- 8 Part Number
6 Color code imbedded in part number
9-23 Item description
24-30 Price in format 9999.99
31 end of line marker

Color codes are 1=Red, 2=Blue, 3=White, 4=Black

My instructor was absent due to illness so everyone in the class was given a video he created that didn't explain anything about this new concept to us. (he often forgets to record and doesn't go back to correct this)

We jumped straight from while loops to this without any introduction except "do it"

He mentioned something in his video about using something to the effect of "nextPipeline" and "myStream" but in no way went into detail about either. I'm completely lost, have searched these forums and tutorials and have found nothing. I'm not asking for the project to be done for me, i just need to understand what in the world is going on.

Ahead of time, any help is greatly appreciated, i don't want to fail before i get started and any guidance whatsoever is a shove in the right direction.

thanks
I don't see the XML output specification anywhere, but that's just something that you need to know for the final result. Right now what you need most is to be told this: You need an XML writer. You either write your own, or you look up one in the Net, or you use the OS-provided MS XML (if in Windows). The thing with MS XML is that it is COM and you are nowhere near understanding COM, so I guess that's out of the question.

If you have studied classes and you understand XML, you should write your own. An XML writer should expose a collection of XML nodes, and each node should expose a collection of XML nodes, making the writer able to write child nodes inside the child nodes inside the child nodes, etc. Each XML node should also expose a collection of attributes too.

In the end, all you need to do, once you have your XML Writer operating, is create a new XML document, and then start adding nodes to the root node, and finally saving the XML node hierarchy to a file.
Well of course you need to know your root node. But breaking it down you'll need functions for reading one line at a time, pulling out each element between delimiters (with a parameter to specify the delimiter comma (ascii #44 or hex 0x2C) , a function that keeps track of the number of characters processed in a given line that pulls out elements based on the range (like 1-8 or the 6th character for color). Obviously commas are used for variable length or optional fields (like names or non-filled data) and fixed lengths are used for standardized fields (like data of birth mm/dd/yy etc). Lastly you'll need a function to dynamically create structures to store the related elements based on the condition that the root cannot be found from pre-existing structures. Reference each structure in an array, or list. Loop through each line until you reach "EOF", storing each element in respective structure along the way.

At "EOF" you then pull out each structure one at a time writing them in xml format in the new file following the xml specification rules.

you'll probably make extensive use of simple getchar() function. Since the number of elements are known beforehand a pre-defined structure should work well. If number of elements are not known beforehand then a binary tree is useful. This is a non-class based solution, but you can easily use classes and even use virtual functions for some sweet polymorphism. It's a good problem b/c it teaches a lot of CS theory.
Topic archived. No new replies allowed.