Edited code to demonstrate new changes. Still need help passing the check 50
My code returns the initials of each name inputted, however I must have something off with the way I implemented it, since the following is consistently being thrown. (If I had to pinpoint the error, I'd say it has to do with taking the first name of the input outside of the loop.)
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
int main(void)
{ //prompt user for input, store input.
printf("Please enter your name.");
string s = GetString();
//prints the first letter of their name in uppercase.
printf("%c",toupper(s[0]));
for(int i=0; i<strlen(s); i++)
{
if(s[i]==32)
{
printf("%c",toupper(s[i+1]));
}
}
}
The error it throws: :( outputs "MB" for "Milo Banana" \ expected output, but not "MB"
:( outputs "MB" for "milo banana" \ expected output, but not "MB"
:( outputs "RTB" for "Robert Thomas Bowden" \ expected output, but not "RTB"
:( outputs "R" for "ROB" \ expected output, but not "R"
:( outputs "RTB" for "Robert thomas Bowden" \ expected output, but not "RTB"