2.2.3.15.25 string::MakeValidCName

Description

Modify a string to be a valid C identifier name. A valid C Identifier name must begin with a letter and can contain only letters, numbers, and underscore characters.

Syntax

void MakeValidCName( char cPrefixIf1stCharNumber = 0 )

Parameters

cPrefixIf1stCharNumber
[input] If not zero and the string begins with a number then this character will be inserted before the first character. If the first character of the string is not a digit or if the specified prefix character is not a letter or underscore then this argument will have no effect.

Return

None

Examples

EX1

void string_MakeValidCName_ex1()
{
    string str = "23 * this & this";
    printf("Before: %s\n", str);
    str.MakeValidCName('a'); // prefix with 'a', delete all spaces, and delete '*' and '&'
    printf("After: %s\n", str);
}

Remark

See Also

Header to Include

origin.h