Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ------------ crap include ------------ //
- #include <iostream>
- #include <string>
- #include <ctime>
- // ------------ crap ------------ //
- namespace crap {
- struct record
- {
- std::string author;
- std::string content;
- std::time_t date;
- };
- record new_record() {
- record n;
- std::cout << "author : ";
- std::getline(std::cin, n.author);
- std::cout << "text : ";
- std::getline(std::cin, n.content);
- std::time(&n.date);
- return n;
- }
- std::ostream & operator<<(std::ostream & os, record const & n) {
- os << "author : " << n.author << '\n'
- << "date : " << std::ctime(&n.date)
- << "text : " << n.content << '\n';
- return os;
- }
- }
- // ------------ main include ------------ //
- #include <vector>
- // ------------ main ------------ //
- int main() {
- std::vector <crap::record> records;
- int const max_records = 3;
- for (int i = 0; i < max_records; ++i) {
- std::cout << "record #" << i << '\n';
- records.push_back(crap::new_record());
- std::cout << '\n';
- }
- std::cout << "all records:\n\n";
- for (int i = 0; i < max_records; ++i)
- std::cout << records[i] << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment