Possible bug in SD.h?

char* name = "Ryan"; // -> name is a char[5] b/c R=1, y=2, a=3, n=4, '\0'=5

strlen(name); // -> 4 b/c strlen doesn't count the null terminator, but it uses the null
// terminator to know when to stop counting

SD init & etc;
File f = init & etc;

int printedBytes1 = f.print(name); // -> printedBytes1 = 4 (prints R,y,a,n, but not nullTerminator
int printedBytes2 = f.println(name); // -> printedBytes2 = 6 (prints R,y,a,n, and a nullTerminator and a '\n'

I think the above information is true and that the above is likely a bug of the oversight / inconsistency variety.

Or maybe I'm just going crazy...

print does NOT print the null terminator.
println DOES print a CR/LF ('\r', '\n'), not just a LF.

Regards,
Ray L.

fml, anyway, there goes 6 hours of fun debugging.

can we change the info on the link found here:
https://www.arduino.cc/en/Reference/FilePrintln

to read

Print data, followed by a carriage return and newline (i.e. 2 additional chars), to the File....

or w/e i'm just dumb for missing it I guess.

All prints only print strlen() characters; it's inherent to how character arrays work. If you need that terminating '\0', you can use the write methods; but in that case you create a binary file and not a text file.

You seem to have a problem with what you're trying to achieve; what are you trying to achieve? I don't think it's simply writing your name to file :wink:

ryanb9:
fml, anyway, there goes 6 hours of fun debugging.

can we change the info on the link found here:
Arduino - FilePrintln

to read

Print data, followed by a carriage return and newline (i.e. 2 additional chars), to the File....

or w/e i'm just dumb for missing it I guess.

It is literally the very first thing the page says:

println()
Description
Print data, followed by a carriage return and newline, to the File

Oh you meant to add the part about it being 2 characters? What, cause people can't count to two?

idk man, i've just never expected a \r \n. I guess arduino conforming to a microsoft-style line ending? but yeah, nothing to see here, carry on.

If you look at ‘standard’ ASCII, the CR and LF perform distinctly different actions... initially required by physical hardcopy / printers etc as an analog of a mechanical ‘typewriter’.
Over the last 30-40 years, various parties have distorted that a bit - calling LF ‘newline’ - implying that it also invokes a ‘Carriage Return’ when it is rendered.

so there.