Hi,
Sorry if the subject isn't right.. I'm quite new at programming in C/C++.. I've done a fair bit of PERL but it feels quite different with the variables.
This code works:
char* filename = "file.txt";
if (! file.open(&root, filename, O_READ)) {
........
}
But I've used String (object) to contain the filename and this code does not.
String filename = "file.txt"
if (! file.open(&root, filename, O_READ)) {
......
}
It produces this error
error: no matching function for call to 'SdFile::open(SdFile*, String&, const uint8_t&)'
/home/shawn/arduino/arduino-0019/libraries/SdFat/SdFat.h:220: note: candidates are: uint8_t SdFile::open(SdFile*, uint16_t, uint8_t)
/home/shawn/arduino/arduino-0019/libraries/SdFat/SdFat.h:221: note: uint8_t SdFile::open(SdFile*, const char*, uint8_t)
/home/shawn/arduino/arduino-0019/libraries/SdFat/SdFat.h:328: note: uint8_t SdFile::open(SdFile&, const char*, uint8_t)
/home/shawn/arduino/arduino-0019/libraries/SdFat/SdFat.h:332: note: uint8_t SdFile::open(SdFile&, const char*)
/home/shawn/arduino/arduino-0019/libraries/SdFat/SdFat.h:338: note: uint8_t SdFile::open(SdFile&, uint16_t, uint8_t)
I thought that perhaps I needed to pass it the pointer reference to the String and I tried using
String filename = "file.txt"
if (! file.open(&root, filename.toCharArray(), O_READ)) {
......
}
And I get this error
error: no matching function for call to 'String::toCharArray()'
/home/shawn/arduino/arduino-0019/hardware/arduino/cores/arduino/WString.h:80: note: candidates are: void String::toCharArray(char*, unsigned int)
Can someone be kind enough to explain to me what I'm doing wrong and how I can fix this?
Thank you.