- #1
- 4,652
- 38
Hello, I have a little function I have written that takes an array of structures as an argument
This is working fine - it prints a number, then a first name, middle name, and last name. The problem is that when I print the middle name I only want to print the first initial. I can't figure out how to print only the first character of the pers_name.middle character string. Thanks for your help.
PHP:
void print_names(struct pers_info arr[])
{
printf("Here is person 1: %d %s %s %s\n", arr[0].ssn,
arr[0].pers_name.first,arr[0].pers_name.middle, arr[0].pers_name.last);
printf("Here is person 2: %d %s %s %s\n", arr[1].ssn,
arr[1].pers_name.first,arr[1].pers_name.middle, arr[1].pers_name.last);
}