Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // D
- import std.stdio;
- import std.file;
- void main(string[] args){
- char[] bytes;
- try
- bytes = cast(char[]) std.file.read("input.txt");
- catch(Exception e){
- writeln("Failed to open file.");
- return;
- }
- try
- std.file.append("output.txt", cast(void[]) (bytes ~ '\n'));
- catch(Exception e){
- writeln("Failed to write to file.");
- return;
- }
- }
- // C++
- #include <fstream>
- #include <iostream>
- int main(int argc, char* argv[]){
- std::ifstream infile("Whatever.txt");
- std::ofstream oufile("Whatever2.txt", std::ios::app);
- if(infile.is_open() && oufile.is_open()){
- char buf[512];
- while(infile.good()){
- infile.getline(buf, 512);
- oufile << buf << '\n';
- }
- }else{
- std::cout << "Failed to open files." << std::endl;
- }
- infile.close();
- oufile.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement