I've written a successful program to complete the Initials section of Pset2 without the use of any functions. However, seeing as I needed to copy/paste a good chunk of code in my program I've decided to declare the copy/pasted part into it's own function and try to get the program to run with that way. Now, unfortunately, I am having problems getting program to compile. Through trial and error I've whittled my errors down to just 1, which reads the following:
initials2.c:32:22: error: unused parameter 'name' [-Werror,-Wunused-parameter]
void PrintCap(string name)
The function I am trying to utilize is for capitalizing each initial. (Note: I am aware of the toupper function within the cstyle lib but as this has not been covered in the course material I am wanting to solve the problem without it.) Any help in assisting me to get this program up and running with this function would be greatly appreciated. Here is my code:
#include <cs50.h>
#include <stdio.h>
#include <string.h>
void PrintCap(string name);
char a;
int main(void)
{
// get name
printf("Please enter your name: ");
string name = GetString();
// print first initial capitalized
a = name[0];
PrintCap(name);
// print following initials capitalized
for (int i = 0, j = strlen(name); i < j; i++)
{
if (name[i] == 32)
{
a = name[i +1];
PrintCap(name);
}
}
printf("\n");
}
// print capital letter function
void PrintCap(string name)
{
if (a >= 97 && a <= 122)
{
printf("%c", a - 32);
}
else
{
printf("%c", a);
}
}