0 Members and 1 Guest are viewing this topic.
If he does it again just turn in one of your calc games to him instead since he apparently knows TI-BASIC
#include <fstream>#include <iostream>void main(){ char string[25]; char header[5][10] = { {"Name"}, {"Address"}, {"City"}, {"State"}, {"ZIP Code"} }; int offset = 0; file_ptr.open("ADDRFILE.DAT", ios::in); if (file_ptr) { do { file_ptr.get(string, 25); file_ptr.ignore(80, '\n'); if (!file_ptr.eof()) cout << header[offset % 5] << ":" << string << "\n"; ++ offset; }...etc
Imagine a project of 6k lines of this and the migraine it would cause, even if its faster. Also, comments are always a good idea whenever clever code is employed.
Code: [Select]#include <fstream>#include <iostream>void main(){ char string[25]; char header[5][10] = { {"Name"}, {"Address"}, {"City"}, {"State"}, {"ZIP Code"} }; int offset = 0; file_ptr.open("ADDRFILE.DAT", ios::in); if (file_ptr) { do { file_ptr.get(string, 25); file_ptr.ignore(80, '\n'); if (!file_ptr.eof()) cout << header[offset % 5] << ":" << string << "\n"; ++ offset; }...etcSo I guess the main point here is, don't over-complicate things, and remember that portability is an issue. Other than that, I would like to say good job on taking the incentive to go above and beyond the accepted normalities; keep the drive going!
What kind of class is it?