Introduction to the programming project. Stuck while creating data file from table

I have been provided with a project for the class and am stuck on its parts. The project has this table:

enter image description here

How can I create this information in a serial file for reading into a C ++ program? It looks like it will be a three-dimensional array. Am I looking too much into this?

+3
source share
3 answers

It depends on what you are trying to do. Usually, if you are just trying to read it, you can save it as a flat file. With flat files, you usually have two common formats for fixed length recording or a comma separately (there are other flat file formats that you can implement, but these are two common fomats).

, .

Turkey             1.00Swiss        .30Roll           .30Condiments         .10
Pastrami           1.30Swiss        .40Roll           .30Condiments         .10

:   , 1,00, , +0,30, Roll, +0,30, , 0,10

con , , , . , , - 99.99, , , - , 5 . , . , .

, ini, ,

Sandwich: Turkey
Deli Slice: Turkey,1.00
Deli Slice: Swiss,.30
Bread: Roll,.30
Condiments: .30

Sandwich: Pastrami
Deli Slice: Pastrami,1.00
Deli Slice: Swiss,.40
Bread: Roll,.30
Condiments: .10

, . , , , , , . ,

Sandwich: California
Deli Slice: Turkey, 1.00
Deli Slice: American, .30
Deli Slice: Avocado, .50
Bread: Roll,.30
Condiments: .10

.

. -, , . . - , ++, strtok, ++.net, , string.split. , "Sandwich", "Deli SLice" .., tokenize itmes,

+1

, . ,

Turkey
Turkey, 1.00
Swiss,  0.30
Roll,   0.30
Condiments, 0.10

Pastrami
Pastrami, 1.30
Swiss,     .40
...

: , /, , . .

0

, HashMaps. , . .

map key = String value = Integer. 4 , "", "", "" "", , , 1,2,3,4.

4 maps, key = String Value = float . 1- , , .

, , , 2D - arrays, . !

0

All Articles