with Ada.Text_IO;
use Ada.Text_IO;
procedure StrngCmp is
MY_CAR : constant STRING := "Ford";
YOUR_CAR : constant STRING := "FORD";
Her_Car : STRING(1..8) := "Mercedes";
Rental : STRING(1..4);
Lease : STRING(1..4);
begin
if MY_CAR /= YOUR_CAR then
Put_Line("Case matters in a STRING constant or variable");
end if;
Her_Car := "Ford "; -- This is still not equal to My_Car
Rental := MY_CAR;
Rental := "Junk";
Lease := Rental;
If Rental = "Junk" then
Put_Line("A variable can be compared to a string literal.");
end if;
end StrngCmp;
052.字符串之间的比较运算
最新推荐文章于 2025-04-28 08:18:35 发布
本文通过一个Ada编程语言的示例,展示了如何比较字符串,并强调了大小写敏感性对字符串比较的影响。示例中,两个看似相同的字符串由于大小写不同而被判断为不相等,同时演示了变量与字符串字面量的比较。
412

被折叠的 条评论
为什么被折叠?



