2.1.2.64 str_end_char


Description

Get the last char of a string

Syntax

char str_end_char( LPCSTR lpcsz, int * nEndPos = NULL )

Parameters

lpcsz
[input] input string
nEndPos
[output] optional pointer to hold last character index, should be (length-1)

Return

-1 if the given string is empty, otherwise the last character

Examples

EX1

void str_end_char_ex1()
{
	string str = "abcdefg";
	int nEndPos;
	int nRet = str_end_char(str , &nEndPos);
	if( -1 == nRet )
		printf("string is empty\n");
	else
		printf("the end char is %c\nthe end position is %d\n", nRet, nEndPos);
}

Remark

See Also

str_pad_char

Header to Include

origin.h

Reference