strlen issue

I seem to he having an issue with the strlen() call.

If I create a string say "char data[20]" and make that "this is a test\r\n" I get back a length of 16

Although that should return a len of 17 with 14 being characters and then one for the \r and one for the \n.

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
 char tdr[20];
 char data[20];
 snprintf(tdr, 20, "this is a test\r\n");
 Serial.println(tdr);
 Serial.print("The length of the string is: ");
 Serial.println(strlen(tdr));
 delay(10000);
}

This is causing all kinds of issues in the sketch I am working on right now because the ESP8266 requires that you give it a string length before sending the string to the unit.

Am I doing this wrong? Is this a bug? How can I get around it?

Although that should return a len of 17 with 14 being characters and then one for the \r and one for the \n.

14 + 1 + 1= ?

CyberLink1:
If I create a string say "char data[20]" and make that "this is a test\r\n" I get back a length of 16

Although that should return a len of 17 with 14 being characters and then one for the \r and one for the \n.

"this is a test" = 14 characters
"\r" = 1 character
"\n" = 1 character

Total 16 characters.
Nothing wrong.

The terminating null character '\0' of a C-string is NOT returned in the strlen.

Ok, so the math in my head was messed up on that one.

CyberLink1:
Ok, so the math in my head was messed up on that one.

Damned hard to fix THAT programming, sometimes.