打印一段字符,这段字符没有0结尾,但是知道长度,如何实现呢:
printf("%.8s", str)
或者
len = 8;
printf("%.*s", len, str);
前者是常量形式,后者可以是变量。
https://stackoverflow.com/questions/2239519/is-there-a-way-to-specify-how-many-characters-of-a-string-to-print-out-using-pri