Looking for the last word on the line:

begin by searching for a space OR a newline, read everything.
if a newline is hit, this is the last word.
if a space is hit, set your index variable (usually i) to 0 and set the
string you used for reading to '\0', like string[0] = '\0'
continue reading the line
repeat

the string you used should hold the last word of the line
by using getchar, you can easily read from input and only store the last word

else you'll have to use another index variable (j perhaps) and never set it to 0, unless the whole line is finished
for reading from file you'll need fgetc (of course)