可將字串插入可以變動的int
用for就可以產生一大批
ex. 1-01.txt, 1-02.txt, 1-03.txt ….等 很像但是有規則的字串
最常用在檔名處理上
sprintf in C:
sprintf(str, “%d”, num);
printf(“str = %sn”, str);
—————————————————————
String.format in Java:
// Store the formatted string in ‘result’
String result = String.format(“%4d”, i * j);
// Write the result to standard output
System.out.println( result );