Any additions for write-to-file short program
pascal111
judas.the.messiah.111 at gmail.com
Thu Nov 18 22:20:48 UTC 2021
In next program that rewrites original written texts into new
files, I see that it may need some additions or we can accept it
like this because it's just a simple program that achieve its
task and doesn't need any philosophical additions.
Example:
Original text:
Learning C doesn't impact bad on C++. In theoretical speaking we
think that C++ is C with some new features, but these features
maybe tends to some high level, and working with C is more
difficult than direct learning of C++, because last one provides
features or tools make us pass some low level ways we have to use
in C to do same tasks, so, the work with C impact good on
learning C++ because we see everything with its real nature in C.
New produced text in new file:
Learning C doesn't impact bad on C++. In theoretical speaking we
think that C++ is C with some new features, but these features
maybe tends to some high level, and working with C is more
difficult than direct learning of C++, because last one provides
features or tools make us pass some low level ways we have to use
in C to do same tasks, so, the work with C impact good on
learning C++ because we see everything with its real nature in C.
Code:
// D programming language
import std.stdio;
import std.string;
int main()
{
string s;
char[] f;
try{
write("Enter file name and path: ");
readln(f);
f=strip(f);}
catch(Exception err){
stderr.writefln!"Warning! %s"(err.msg);}
File file = File(f, "r");
File file2 = File("output_x.txt", "w");
while (!file.eof()) {
s = chomp(file.readln());
file2.writeln(s);
}
file.close();
file2.close();
return 0;
}
More information about the Digitalmars-d-learn
mailing list