I am currently trying to make my program so that it has the file name as the persons name + their date of birth. The issue i am having is copying just the name into the array, as I currently have a loop where it loops 15 times. I am unsure of how I am able to limit the program to only loop the amount of times as there were input by the user, or to make the program stop when it reaches the end of the user input characters in the array.
#include <stdio.h>
#include <conio.h>
#include <string.h>
int main()
{
char firstname[16], lastname[15], filename[23];
int dob, i;
printf("Please enter the first name of the player:");
fgets(firstname, 15, stdin);
printf("Please enter the date of birth of the player(ddmmyy): ");
scanf("%6d", &dob);
for(i = 0; i < 15; i++)
{
strncpy(filename[i], firstname[i], 15);
if(lastname[i] == '\0');
{
break;
}
}
for(i = 0; i < 6; i++)
{
strncpy(filename[i+14], dob, 6);
if(dob[i] == '\0');
{
break;
}
}
printf("%s", filename);
}
firstnameaswell