Hi, Jerry Coffin!
FM> c=30;
FM> clrscr();
FM> gotoxy(c,10);
FM> textcolor(14);
FM> cputs("Would you like to practice a little ");
JC> [ more similar stuff elided ]
JC> While this works perfectly fine the way it is, you might consider
JC> separating the data from the code.
Good idea. :)
JC> /* file format */
JC> num_entries
JC> label, x, y, color
JC> label, x, y, color /* repeated a total of num_entries times */
JC> stream.getline(label_, 256); // discard leading junk.
JC> stream.getline(label_, 256, ',');
I'd better use sizeof(label_) instead of the number. If you happen to change
the size you can do it in one and only place.
JC> #include
JC> int main() {
JC> ifstream input("menu.dat");
JC> menu m;
JC> m.read(input);
JC> m.show();
JC> return 0;
JC> }
Just another idea for the final use. If one dislike a separate file with
menu, it can placed into a single string as is. (Well, adding some " and \n's
:) Then in the processing session just make this string a strstream and use
the very same way as above.
Paul
... If it's not on fire, it's a software problem
--- OS/2 Warp
---------------
* Origin: The FlintStones' Cave in BedRock (2:371/20)
|