60 likes | 180 Vues
This project focuses on enhancing C++ programming skills through practical file handling and ASCII art creation. Key skills include appending data to existing files using `ofstream`, modifying specific file lines with `seekg` and `seekp`, and managing date and time in file operations. Students must complete Part 1 today and submit both parts by 8/3. Resources such as the ASCII art generator at schnoggo.com will aid in creativity. Understanding these concepts is crucial for aspiring developers.
E N D
Project 2 Overview Start Part 1 Today Part 2 handed out later Turn in both by 8/3
New Skills Needed • Working with ASCII Art • How to append to an existing file • ofstream trans(“transactions.txt”, ios::app); • How to jump to one line of file and modify • seekg and seekp • fstream accts("accounts.txt", ios::in | ios::out); • Accessing Date/Time
fstream accts("accounts.txt", ios::in | ios::out); accts.seekg(recordNum*BYTES_PER_REC, ios::beg); accts>>userID>>name>>PIN>>balance; … … accts.seekp(recordNum*BYTES_PER_REC, ios::beg); accts<<userID<<" "<<name<<" "<<PIN<<balance; accts.close(); Using seekg/seekp Formatting removed for clarity (but is very important!)
Working with ASCII Art • Visit www.schnoggo.com/figlet.html • Replace \ with \\
Date and Time char dateStr[9], timeStr[9]; // time and date vars _strdate(dateStr); // dateStr now has date _strtime(timeStr); // timeStr now has time #include<ctime>