2014-04-25 12 views
0

我想在Ada 83中打印整數。目前我只使用'with Text_IO'和'use Text_IO'。我不想使用Integer'圖像選項進行打印。我想在ada83中使用Integer_Text_IO。請幫助我解釋語法。如何在ada83環境中打印整數

我使用下面的代碼:

with Text_IO; 
use Text_IO; 
i: INTEGER :=1; 
package Int_IO is new Integer_IO(INTEGER); 
use Int_IO; put(i); 

我得到「預期‘數’的實例化符號整型」的錯誤。

+0

到目前爲止您有試過什麼嗎?請提供一些代碼示例。 – xlembouras

+0

與Text_IO;使用Text_IO; i:INTEGER:= 1;包Int_IO是新的Integer_IO(INTEGER);使用Int_IO;放(ⅰ);在'Num''實例化'錯誤中,我期待得到'有符號整數類型'。 – user3574764

+0

我假設在那裏有一些額外的行,如'過程'或'函數'聲明和'開始'?假設有,並且你已經把上面的語句放在正確的地方,它應該工作得很好,除非你做了像重新定義INTEGER之類的東西。 – ajb

回答

1

以下編譯示例應該有所幫助。

但是,請在StackOverflow(或網絡上的任何地方)發佈問題時向我們展示您實際嘗試的代碼。您提供的示例沒有接近編譯(它在第3行失敗compilation unit expected),這使我們很難制定出如何爲您提供幫助。

如果您嘗試使用錯誤的類型實例化Text_IO(例如,Float),則會得到expect signed integer type in instantiation of 「Num」

with Text_IO; 
procedure Integer_IO_Demo is 
    package Int_IO is new Text_IO.Integer_IO (Integer); 
begin 
    for J in 5 .. 10 loop 
     Int_IO.Put (J); 
     Text_IO.New_Line; 
    end loop; 
end Integer_IO_Demo;