it's nice to be here!
In initials.c
in pset2, I am able to extract and capitalize (if necessary) the first letter of the inputted name string, iterate through the string and extract and capitalize any subsequent initials immediately following a space, however the printed output contains garbled non-ascii characters so I'm clearly doing something wrong..
Here is the relevant trimmed code:
if (name != NULL)
{
for (int i = 1, n = strlen(name); i < n; i++)
{
if (name[i] == ' ')
{
initials[i] = toupper(name[i+1]);
}
}
printf("%s\n", initials);
}
And a couple of examples of the output:
jharvard@appliance (~/Dropbox/pset2): ./initials
Robert thomas Bowden
R�8yT�
jharvard@appliance (~/Dropbox/pset2): ./initials
Just another name
J�A�s�
jharvard@appliance (~/Dropbox/pset2): ./initials
a l s
ALS8 r�
I was wondering if the garbage between the initials is being created when I iterate over the unused letters, or if it is a function of not recognising the end of the string correctly..?
I feel like I can nearly grasp what's happening but it's just out of reach..