main(), in the third line, you have
void setInitials(string name);
which, if I guess correctly, is the prototype for the function
main(). If so, you should put the prototype outside any other function, and at the top of your source file, right after the
In your set initials, you have the loop
for (int i = 0; i < strlen(name);i++)
which at the start of every loop, computes the length of the
name, which doesn't change inside the loop. Instead, consider computing the length only on the first iteration of the loop, to speed it up, like so:
for (int i = 0, length = strlen(name); i < length; i++)
setInitials(), inside the
if(isspace(name[i])), you have
It's generally considered bad practice to increment inside a
for loop, the variable that controls the
for loop. Consider using a
while loop instead.
for loops are usually used when you know the exact number of times the loop will run, which in your case is not true, since you increment
i based on some condition, inside the loop.
Bare in mind that your question in primarily opinion based and such questions are not so welcome in SE. Nevertheless I tried to answer your question as objectively as I could based on best practices I use myself.