Thanks for your help, huge mistake with the returned value from strcmp !
Here is the full code :
#include <SdFat.h>
SdFat sd;
SdFile prev, file;
char nextApp[30] = {0};
void setup() {
// put your setup code here, to run once:
sd.begin(SD_CS_PIN, SPI_FULL_SPEED);
while (!SerialUSB);
if (prev.open("/System/Loader/NEXTAPP.TXT", O_READ))
{
char c = 0;
int i = 0;
String s = "";
digitalWrite(13, HIGH);
memset(nextApp, 0, 30);
while (c != '\n')
{
c = prev.read();
if (c != '\n')
{
s += char(c);
nextApp[i] = c;
i++;
}
}
prev.close();
SerialUSB.println(strcmp(s.c_str(), "/Test/Test.bin") ? "\"/Test/Test.bin\" differs from \"" + String(s.c_str()) + "\"" : "Match");
SerialUSB.println(strcmp(nextApp, "/Test/Test.bin") ? "Differ" : "Match");
SerialUSB.print("i = ");
SerialUSB.println(i);
SerialUSB.print("s.length() = ");
SerialUSB.println(s.length());
if (file.open(nextApp, O_READ))
{
SerialUSB.println("File open success using char *");
}
else if (file.open(s.c_str(), O_READ))
{
SerialUSB.println("File open success using c_str()");
}
}
}
void loop() {
// put your main code here, to run repeatedly:
}
Which displays this on the Serial port :
"/Test/Test.bin" differs from "/Test/Test.bin"
Differ
i = 19
s.length() = 19