Reading text line by line from SD Why does the following code return this error?  How can I make this work?


  Error: exit status 1 invalid conversion from 'const char*' to 'char'
  [-fpermissive]


#include "FS.h"
#include "SD.h"
#include "SPI.h"

void setup() {
  Serial.begin(115200);

  if (!SD.begin(33)) {
    Serial.println("Card Mount Failed");
  } else {
    Serial.println("Card Mount Succeeded");
  }

  File offline = SD.open("/offlineLog.txt", FILE_READ);

  while (offline.available()) {
    String line = offline.readStringUntil("\n");
    Serial.println(line);
  }
}


The docs say that stream.readStringUntil returns a string...
The error has nothing to do with what readStringUntil returns. It has to do with what parameters it accepts.

The function expects a single character to look for. Instead you are passing it a string (C string) containing one character.

In C you represent a string (char *) using "", and a single character (char) using ''.

Since readStringUntil expects a char, not a char *, you need to use '':

String line = offline.readStringUntil('\n');