I am attempting to create a library that will hold a function for opening a file with a user-input name, and also a function for reading the contents of said file. I am new to creating library's and I am receiving an error in the constructor of my header file saying that it is looking for an unqualified-id before the second parenthesis. I have cross-checked my code with a team member's header and all seems to fit. Any ideas?
.cpp file:
#include "Arduino.h"
#include "interactSD.h"
#include <SPI.h>
#include <SD.h>
interactSD::interactSD()
{
}
void interactSD::getFilename()
{
userInput = Serial.readString();
userInput.trim();
userInput.concat(".TXT");
fileName[userInput.length() + 1];
userInput.toCharArray(fileName, userInput.length() + 1);
}
void interactSD::readFile()
{
userFile = SD.open(filename, FILE_READ);
while (userFile.available()) {
Serial.write(userFile.read());
}
userFile.close();
Serial.println("done");
}
.h file:
#ifndef interactSD
#define interactSD
#include <SPI.h>
#include <SD.h>
#include "Arduino.h"
class interactSD
{
public:
interactSD(); //line with the error***
void readFile();
void getFilename();
char fileName[];
String userInput;
File userfile;
}
;
#endif
Thanks for your help!