PT_PointString

PT_PointString — converts a point to a string.

Syntax

#include <cogent.h>
char* PT_PointString(PT_pCPOINT  point,
 char*  format,
 char*  buffer);

Arguments

point

The point whose value is to be returned.

format

A printf-style format directive used to format the point value. Only the actual formatting directive, beginning with % and ending with one of [sfgGeEdicouxX] is acceptable. If this argument is NULL, then default formatting will be done.

buffer

A character buffer to be filled with the formatting result. It is the programmer's responsibility to ensure that the buffer is large enough to hold the formatted point value.

Returns

A pointer to a buffer containing the formatted value. This may or may not be a pointer to the input buffer. In any case, it is not subject to memory management (free or realloc), though buffer may be.

Description

This function attempts to produce a character string that represents the point value. Integer and real values will be written to the buffer using sprintf along with the format string. If no format string is given, then %g is used for real, and %d is used for integer. If %s is given to a point which not of type string, then the value will first be formatted into a string using the default style, and then formatted again using the %s directive in order to achieve the necessary spacing (e.g., formatting the integer 5 to "%-s" will generate a right-justified string as "5"). The return value will be either a pointer to the point value (in the case of an unformatted point of type PT_TYPE_STRING), or a pointer to the argument buffer.

See Also

Point Structure, Storage, and Manipulation, PT_PointInt, PT_PointReal, and PT_PointFormat