StrCpy

From ZDoom Wiki
Jump to navigation Jump to search

bool StrCpy (a:destination, string source[, int source_index]);

Usage

Copy a source string to a destination array as a series of characters. Optionally, the copy can start from a given index in the source string.

Return Value

True if the entire string (or substring) was successfully copied to the array; false if the copy ran out of room or if a negative source_index was given.

Example

This function returns true if the map lump is in the form "ExMx". It copies the string to a char array, then it compares individual characters at 2 positions, and skips the character in IsMap_LumpChar[1].

int IsMap_LumpChar[8];
str IsMap_LumpStr;

function bool IsMap_EXMX (void)
{
	if(StrCpy(a:IsMap_LumpChar, IsMap_LumpStr))
	{
		int c_e = IsMap_LumpChar[0];
		int c_m = IsMap_LumpChar[2];
		
		return(  (c_e == 'e' || c_e == 'E')  &&  (c_m == 'm' || c_m == 'M')  );
	}
	return FALSE;
}