You indicated above what the max size (length) of a first name or last name may be, however you did not specify what would be the minimum size (presumably a single character would suffice?). Anyhow, you shouldn't assume the last name begins at offset 41 unless the conjoined string is set up that way.
Originally Posted by Xender1
Is there any field separator between the first and last names? If so, then it may be possible to use strchr() to find that point in the string, thus giving you a reference point as to where one string ends and the next begins.
Maybe the following will give an idea:
const char* first_last = "Fred Flintstone";
const char* space = strchr(first_last, ' '); // assume space-character separator
const char* end = strchr(first_last, '\0'); // look for terminating null-character
char* first = malloc(space - first_last + 1);
char* last = malloc(end - space);
snprintf(first, space - first_last + 1, "%s", first_last);
snprintf(last, end - space + 1, "%s", space + 1);
char* first = strndup(first_last, space - first_last);
char* last = strndup(space + 1, end - space);
printf("first name is: %s\n", first);
printf("last name is : %s\n", last);