substr是什么?在systemverilog中

what is the substr? in the systemverilog

Int fd;
String str;

fd = $fopen(path, "r");
Status= $fgets(str, fd);
cm = str.substr(0,1);
cm1= str.substr(0,0);

我想知道什么是substr功能?那上面的目的是什么??

Substring:此方法提取字符串。它需要子字符串的位置(起始索引、长度)。然后 returns 一个包含该范围内字符的新字符串。

C# 程序子字符串

使用系统;

class Program
{
    static void Main()
    {
    string input = "ManCatDog";

    // Get Middle three characters.
    string subString = input.Substring(3, 6);
    Console.WriteLine("SubString: {0}", subString);
    }
}

输出

子字符串:猫

substr函数returns一个新字符串,它是由str的位置i到j的字符组成的子字符串。与此处发布的示例非常相似。

module test;
  string str = "Test";
  initial
    $display(str.substr(0,1));
endmodule

输出将是:

>> Te

如您在第 6.16.8 节中所见,IEEE SystemVerilog Standard 1800-2012

substr 函数,顾名思义,在 systemverilog 中从较大的字符串中减去或获取块。

示例:

stri0 = "my_lago";
stri1 = stri0.substr(1,5);
$display("This will give stri1 = %s" , stri1);

..... 输出:- 这将给出 stri1 = y_lag