Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: SD open issue

  1. #1

    SD open issue

    Can someone tell me why this compiles ok on my 3.2

    myFile ="filename", FILE_WRITE);

    But this doesn't compile?

    String filename = "asdf.txt";
    myFile =, FILE_WRITE);

    Caused errors compiling.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    The reason why is involves some history of Arduino. It's really just C++ and from the beginning everything used ordinary C strings. Even though the String C++ class was added to Arduino about 10 years ago, the reality is most libraries still only accept C type strings.

    So to give a C++ String to a function which wants a C string, you need this:

    myFile =, FILE_WRITE);

  3. #3
    Never mind. Figured it out. it seems i cannot us a String variable there.

    Thanks Paul!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts