0

don't understand why it show error

:) initials.c exists
:) initials.c compiles
:( outputs "MB" for "Milo Banana"
   \ expected prompt for input, not output of "Input you name\n"
:( outputs "MB" for "milo banana"
   \ expected prompt for input, not output of "Input you name\n"
:( outputs "RTB" for "Robert Thomas Bowden"
   \ expected prompt for input, not output of "Input you name\n"
:( outputs "R" for "ROB"
   \ expected prompt for input, not output of "Input you name\n"
:( outputs "RTB" for "Robert thomas Bowden"

code:

string s = GetString();

printf("%c", toupper(s[0]));

for (int i = 1, n = strlen(s); i < n; i++)
{
   if (s[i] == ' ')
   {
     printf("%c", toupper(s[i+1]));
   }
}
1

Because the psets are graded programmatically, you should make sure that you follow the instructions exactly:

So that we can automate some tests of your code, your program must behave per the examples below. Assumed that the underlined text is what some user has typed.

username@ide50:~/workspace/pset2 $ ./initials
Zamyla Chan
ZC
username@ide50:~/workspace/pset2 $ ./initials  
robert thomas bowden
RTB

Notice that there is no printed message asking for the name. Your program should behave the same way.

0

The instructions seem to be a bit misleading in asking for a prompt. Try commenting out the printf("Input you name\n"); line and see if it passes. It may be an oversight in the updating of course material from last year.

Also you could compare your output to the output generated by the staff sample program and see how it's different.

If this answers your question, please click the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .