Advertisement
Guest User

Untitled

a guest
Jan 30th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.60 KB | None | 0 0
  1. import std.stdio;
  2. extern(Windows)
  3.     bool  SetConsoleCP(
  4.          uint wCodePageID
  5.         );
  6.  
  7. extern(Windows)
  8. bool SetConsoleOutputCP(
  9.     uint wCodePageID
  10.     );
  11.  
  12. //extern (C) bool SetConsoleCP(uint wCodePageID);
  13. int main(string args[])
  14. {
  15.  
  16.     File file;
  17.     try
  18.     {
  19.         file.open("C:\\Windows\\System32\\Drivers\\etc\\hosts","r");
  20.     }
  21.     catch(StdioException e)
  22.     {
  23.         writeln(e);
  24.         return 1;
  25.     }
  26.  
  27.     int countLines;
  28.     while(!file.eof())
  29.     {
  30.         write(file.readln());
  31.         ++countLines;
  32.     }
  33.     SetConsoleCP(65001);
  34.     SetConsoleOutputCP(65001);
  35.     writeln("Количество строк равно: ", countLines);
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement