= sprintf =
== Syntax == :int sprintf (char * str, const char * format, ... ) == Arguments == :buffer ::A pointer to the string buffer where the result will be stored :format ::Specifies the format of the resulting string, including types of the variables to be included in the string. == Return == :The number of characters written, not including the terminating null character, or -1 if an error occurred. == Description == :sprintf "prints" a formatted string, except instead of printing it to a terminal console, it stores the result in a string variable. The formatting uses the printf-style formatting common to the C language. == Comments == :Wherever possible, you should use snprintf instead. sprintf can have potential buffer overruns (crashes) depending how it is used - snprinf prevents the overruns. == Example == <code> int version = 1; strcpy(str0, "Plug-In Name"); strcpy(str1, "Company Name"); sprintf(str2, "You are running %s made by %s, version %d", str0, str1, version); printf(str2); </code> == See Also == |