I made some changes to your code to print the last character. Here is test.c as a sample:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
FILE * f;
char * f_text = "temp.txt";
f = fopen ( f_text, "r" );
if (f )
{
if (fseek( f, -2, SEEK_END ) == 0 )
{
char last[2] = {0};
printf("Got here.\n");
last[0] = fgetc( f );
printf("%s\n", last);
}
}
return 0;
}
and here is temp.txt displayed at the command line.
octopusgrabbus@steamboy:~/scratch$ cat temp.txt
This is a test.
octopusgrabbus@steamboy:~/scratch$
I changed your fseek to seek two from the end, so test would print the period.
As another answer indicated, I used fgetc instead of fgets, because you were
looking for an individual character, not a full string.
I also changed last to last[2] and initialized to zero, so I could treat
the last character as a zero-terminated string for demo purposes.