SD.Fat Library

I am new to this board and not sure if this was the correct place to post this question. I am working with the latest version of SDFat. I am modifying the DataLogger example to take load cell readings as quickly as the HX711 board can send them. I intend to cut the jumper which will place the HX711 in the 80 samples per second mode. I have calculated that 80 samples per second is aprox a sample every 0.0125 seconds. To be on the safe side I have set the scan time of the datalogger to 25 milliseconds. This should take care of any latency in the system. I have been going through the code adding remarks where ever I feel they needed. I have come to a line of code which baffles me.

const uint8_t BASE_NAME_SIZE = sizeof(FILE_BASE_NAME) - 1;

This line is fairly simple to read. The line assigns a value equal to the length of FILE_BASE_NAME Which is an integer equal to '5' and then "1" is subtracted. This leaves BASE_NAME_SIZE at a value of "4".

char fileName[] = FILE_BASE_NAME "00.csv";

This line defines a character array of undeterred size. The filename array is assigned a value of the string constant " FILE_BASE_NAME. This is where my experience fails me. Is the string literal "00.csv" being added to the FILE_BASE_NAME? I don;t see any operator which indicates any kind of addition. It would make sense to add a incrementing end to the file name to allow multiple files to be recorded to the SD Card.

I am going to research the literal string to see if there are any answers there

Thank you for any input you can give me.

Charles O

The FILE_BASE_NAME macro is a string literal:

#define FILE_BASE_NAME "Data"

So this is the equivalent of:

char fileName[] = "Data" "00.csv";

C++ automatically concatenates adjacent string literals, no operator is needed. This is a useful feature in this case.

charles1954:
This line defines a character array of undeterred size.

When you initialize the array, the size is automatically set.

Thank you for the reply. I understood where they were going, but was unaware of that little tidbit about C. My most recent experience with the C language is over 20 years old. I guess its time to dust off some old books and study a little. Again Thank you for your reply, I can carry on now with my programming.

Charles O