【问题标题】:Throwing error while printing record element string?打印记录元素字符串时抛出错误?
【发布时间】:2014-11-25 16:59:50
【问题描述】:

使用put打印记录元素字符串时抛出错误为什么请帮我理解?

 with ada.text_io;
 use ada.text_io;

procedure main is
  type my_rec is record
    name:string(1..5)of integer; 
  end record;
var:my_rec;

begin
var.name:="hello";
put(var.name); -- why error?
end main;

错误信息如下

 cc -c hello.adb                                                                
 hello.adb:7:27: missing ";"                                                     
 gnatmake: "main.adb" compilation error  

【问题讨论】:

  • 嗯...string(1..5) of integer 是什么?
  • 我永远不会明白这一点。人们收到错误消息,然后他们寻求帮助以理解错误消息,但他们实际上并没有向我们展示消息是什么,而是假设我们可以以某种方式从我们坐的地方一直阅读他们的屏幕。
  • 错误是“缺少分号”就在of integer; ...看图
  • @ajb 抱歉这里有错误消息 cc -c hello.adb hello.adb:7:27: missing ";" gnatmake: "main.adb" 编译错误
  • 我认为name 应该只是string(1..5)。我不知道of integer 想要完成什么。它绝对不属于那里。

标签: record ada


【解决方案1】:

hello.adb:7:27 是错误的坐标,因此请查看第 7 行第 27 字符位置的“hello.adb”。

【讨论】:

    猜你喜欢
    • 2017-09-18
    • 1970-01-01
    • 1970-01-01
    • 2018-07-18
    • 1970-01-01
    • 1970-01-01
    • 2013-12-13
    • 2015-08-24
    相关资源
    最近更新 更多