当我尝试在我的 for 循环中使用“i < n”时出现错误(准确地说是 4)。如果我把它拿出来,我会得到一个无限循环。我似乎也无法运行 if 语句。关于我可以改进的任何想法?
int main()
{
int i;
int n;
//Program to get the user's name and reply with their capitalized initials
{
//Ask user for their name
printf("What is your full name?\n");
}
//look for 1st character of each part of name given
string name = GetString();
for (i = 0; (n = strlen (name)); i < n; i++)
{
printf("Your intitals are %c", toupper(name[0]));
{
if (isspace(name[i]))
{
printf("%c", toupper(name[i+1]));
}
printf("!\n");
}
}
return 0;
}