Skip to content

Instantly share code, notes, and snippets.

@bugaevc
Last active May 2, 2016 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bugaevc/6c0cd33441215fbf4d1791adb0528e90 to your computer and use it in GitHub Desktop.
Save bugaevc/6c0cd33441215fbf4d1791adb0528e90 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
const char *last_name(const char *full_name)
{
return strrchr(full_name, ' ') + 1;
}
int main() {
const char *buffer = strcpy(malloc(80), "Harry Potter");
const char *res = last_name(buffer);
free(buffer);
printf("%s\n", res);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment