what is different between %s and %0s?(%s和%零s)
%s prints the string as it is with spaces at the begining if string contents
are less than string variable size.
whereas %0s supress printing spaces.
(如果字符串的内容小于字符串变量的尺寸,%s打印字符串时前面会添加空格;而%0s不会添加空格(字符串顶头打印))
Here is an example. Hope this helps!
Code:
module test(); reg [10*8:0] str = "hello"; initial begin $display("%s", str); $display("%0s", str); end endmodule // test
时间: 2024-10-08 10:03:57