C string manipulation (C not CPP)

Hello,
I'm usually a c++ programmer but my teacher is forcing me to use regular old c.
I've been spending a lot of time figuring out how to manipulate strings. For instance the strncmp, strncat, and strcpy functions.

My question:
Is there a clean way to convert dir/dir/dir/filename.ext to filename.ext.
example:
input: home/user/hello.c
output: hello.c

I can think of at least one way to do this: iterating backwards and keeping count of how many chars the filename has. Then iterating over just that section and copying each char one by one. This seems like a brute force method to me and I was hoping someone could point me to a better way of doing this.

Thank you in advance!
Sure:
1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
#include <string.h>

int main()
{
    char input[] = "home/user/hello.c";
    char* output = strrchr(input, '/');
    if(output)
        puts(output+1);
}

demo: http://ideone.com/uZehwx
Beautiful. So glad I asked! =D
Topic archived. No new replies allowed.