Basically the program should split the name into F and L names. User puts in their name either combined or with a space (ex. AlexTank or Alex Tank). The program should read in every capital letter and split the string with a space. The issue I have is that my program splits the name (recognizes uppercase letters) but excludes the upper case letters from the new output of the string.
#include <stdio.h>
#include <string.h>
int main()
{
char name[50], first[25], last[25];
char *pch;
char* key = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// ask user for name
printf("What is your name? ");
scanf("%s", name);
printf("Hello \"%s\" here is your First and Last Name:\n", name);
pch = strtok(name, key);
while (pch != NULL)
{
printf("%s\n", pch);
pch = strtok(NULL, key );
}
return 0;
}