Last active
April 18, 2019 07:07
-
-
Save andraantariksa/da676654af4b39f2b36c9d0ef4b16717 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include <iomanip> | |
int main(int argc, const char *argv[]){ | |
std::string name, surname, city; | |
std::fstream file; | |
file.open("output.txt", std::fstream::in | std::fstream::out | std::fstream::app); | |
std::cout << "Write the detail with these format. Press <Ctrl+D> to send EOF to program.\nName Surname City\n"; | |
if(file.peek() == std::ifstream::traits_type::eof()){ | |
file << std::left << std::setw(10) << "Name" << std::setw(15) << "Surname" << std::setw(15) << "City" << '\n'; | |
} | |
while(std::cin>> name >> surname >> city){ | |
file << std::left << std::setw(10) << name << std::setw(15) << surname << std::setw(15) << city << '\n'; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment