What is the Ada command line redirector that is analogous to “>”?

后端 未结 3 1685
醉梦人生
醉梦人生 2021-01-25 01:37

Ada noob here (and also not so hot with the command line in general). I am looking for the Ada command line redirector that would be analogous to \">\" in DOS.

I am r

3条回答
  •  余生分开走
    2021-01-25 02:27

    The package Ada.Command_Line is for receiving command line arguments, when an Ada program starts. What you are interested in is most likely Ada.Text_IO (chapter A.10 in the RM).

    More specifically, you will need to declare a variable for representing the file you are going to redirect standard output to:

    Redirection : Ada.Text_IO.File_Type;
    

    Then create and open it:

    Ada.Text_IO.Create (File => Redirection,
                        Name => "latin.words",
                        Mode => Ada.Text_IO.Out_File);
    

    Finally you can redirect standard output:

    Ada.Text_IO.Set_Output (File => Redirection);
    

提交回复
热议问题