I'm new to c programming and working with little knowledge of it.
I'm writing a program to read a name into the console and split it up into first middle last name.
I've tried many things excluding tolkens because I don't know about them yet. With what I know so far I can't understand why this doesn't work.
Code:
#include <stdio.h>
#include <string.h>
char full_name[100];
char first_name[50];
char last_name[50];
int ch;
int main()
{
printf("Enter full name: ");
fgets(full_name, sizeof(full_name), stdin);
if(full_name[0] == ' ')
{
printf("Error reading name\n");
getchar();
return 1;
}
int i=0;
while(full_name[i]<strlen(full_name))
{
strcpy(first_name[i], full_name[i]);
++i;
}
printf("First name: %s \n", first_name);
getchar();
return 0;
}