Skip to main content
Open topic with navigation CAPL Functions » General » Function Overview » snprintf

snprintf

Valid for: CANoe DE • CANoe:lite DE • CANoe4SW DE • CANoe4SW:lite DE

Function Syntax

long snprintf(char dest[], long len, char format[], ...);

Description

This function corresponds to the C function sprintf. Supplementally, the parameter len indicates the maximum length of the array dest. The format string has the same meaning as with the function write and is described there. Note: CAPL supports a function call with maximum 64 parameters.

Parameters

  • dest: Character buffer to print to.
  • len: Maximum number of characters printed to buffer including terminating ‘\0’. Must be at most the size of the buffer.
  • format: Formatted string printed to buffer.

Return Values

The number of characters written.

Example

char buffer[100], str[7] = "Vector";
long i;
i = snprintf(buffer, elcount(buffer), "String: %s\n", str);
write("Output:\n%s : Character count = %d\n", buffer, i);
writeString Literal