im not too sure what sprintf do here, "%%%ds" and i know this format the argument but i search it means %4s? but im not sure how can i understand it,Code:// enum { SZ = 250 } ; char cstr[SZ] ;// prepare format string to read at most SZ-1 characters char format[16] ; sprintf( format, "%%%ds", SZ-1 ) ; // ie. "%249s" if SZ == 250 scanf( format, cstr ) ;
my guess is it formatted string of max 250 to array format, but why char format[16]?
and in scanf(format, cstr) what the role of scanf? is cstr argument?
thankyou!