Can't compare sprintf() result with a char array

Hello everyone.
I’m making some logs in an SD card and with each new day a new file is created. Now i want to make another log file which will contain all the dates when i logged some data. Each date should obviously only appear once. The code doing this is as follows:

char currentDate[12], previousDate[12];
int m, d, y, lastLine;
.
.
.
m = rtc.getTime().mon;
d = rtc.getTime().date;
y = rtc.getTime().year;
.
.
.
logDates = SD.open("LOGDATES.TXT", FILE_READ); // We need to read the last log date so we can avoid rewritting it
    sprintf(currentDate,"%02d/%02d/%04d", m, d, y); // The current date
    lastLine = logDates.size()-12; // Each line has 12 characters: mm/dd/yyyy\n\r so by moving 12 places before the end we get to the beggining of the last line
    if (lastLine < 0) {
      lastLine = 0; // In case its the 1st time we're going to write in this file
    }
    logDates.seek(lastLine); // The cursor is moved in the beggining of the last line
    logDates.readStringUntil('\n').toCharArray(previousDate,12); // Get the last recorded date
    logDates.close(); // We got what we needed so now the file gets closed
    if (currentDate != previousDate) { // If a new log date was detected then write it down
      logDates = SD.open("LOGDATES.TXT", FILE_WRITE);
      logDates.println(currentDate);
      logDates.close();
    }

This seems to be working except for 1 part: When i check if the currentDate equals the previousDate then it always returns false even when they seem to be idential (using Serial.print() to check them). I guess the problem will have to do with the data types but i’m not sure what should i do. Any ideas how i can correctly compare them?

You can't compare C strings that way. You will need to use strcmp. The somewhat counterintuitive reason is that you're actually comparing the addresses of the strings rather than their contents.

Thank you very much! everything is working great now.