help with String manipulation

GoForSmoke:
Not without terminating zeros. Go ahead and try.

Sure

// Return true if a valid cmd "xxxOyyy|" , false if not
// output parameters xx and yy
bool parse_O_command( const char * str, int & xx, int & yy)
{
	// "Input string should arrive in the format of 255O255|"
	if ( strnlen(str,8)== 8 && str[3]=='O' && str[7]=='|'){
		xx=atoi(str);	   // the first 3 characters are the Slave device address
		yy=atoi(str+4);    // str[4] and after are digital value
		return true;
	}
	return false;
}

Test Suite

void setup(){

	int adr, val;
	bool valid;

	valid = parseOcommand("123O456|", adr, val);
	Serial << "1: " << adr << "," << val << " : " << (valid?"valid":"not a valid") << " O command" << endl;

	char buf8[8] = {'2','4','6','O','1','8','8','|'};
	valid = parseOcommand(buf8, adr, val);
	Serial << "2: " << adr << "," << val << " : " << (valid?"valid":"not a valid") << " O command" << endl;

	char buf7[7] = {'2','4','6','O','1','7','7'};
	valid = parseOcommand(buf7, adr, val);
	Serial << "3: " << adr << "," << val << " : " << (valid?"valid":"not a valid") << " O command" << endl;

	Serial << "Done" << endl;
}

Output

1: 123,456 : valid O command
2: 246,188 : valid O command
3: 246,188 : NOT valid O command
Done