getline function

hello good day,
we make a door lock project based on RFID, our problem is were having trouble on how to get line by line inside the text file… Were using SD card as mass storage.

scenario:

swipe the card then check if the ID exist inside the textfile (users.txt).
if yes , get the ID(ID of the card) and name inside the textfile from users.txt —>this is our problem
then, place in logs.text…
unlock the door
if no, it remains lock.

please respect , thank you. :slight_smile: Godbless

Each line in the file will end with a delimiter, probably a linefeed. Read characters from the file into a char array and when you get a linefeed add a zero to the end of the array to turn it into a C style string. Compare the string with the code from the RFID. If it matches then read the next line from the file to get the name. If no match then carry on until EOF or you get a match.

The file should look like 1234 Name one 2211 Name two 19191919 Name three

It would be neater if the file were like this 1234,Name one 2211,Name two 19191919,Name three

and you used the comma as the delimiter.

thanks for the advice sir.. our problem is we dont know how to code to compare between the ID of RFID and the ID stored in SD Card.. specifically to loop the comparing code for ID's. can you please help us sir ? please ?. we really need your help ..

Depending on exactly what you're doing, the strcmp() function might be what you're looking for.

If it isn't, keep looking around that site as it has a wealth of information on all the functions available which aren't mentioned in the Arduino documentation.