0

I have figured out how to print the first initial. I need help with printing the second initial. I know that you have to test for a space and then print the letter after the space. How do you print the letter after the space?

 #include <cs50.h>
 #include <stdio.h>
 #include <string.h>

 int main(void)

{
   string s = GetString( );

 if (s[0] >= 'a' && s[0] <= 'z')
 {
     printf("%c", s[0] - ('a' - 'A'));
 }
 else
 {
     printf("%c", s[0]);
 }
 printf("\n");

 if (s[i] = \0)

}

1 Answer 1

0

You can use a for loop to look for the space. Let's say it occurs at position i. Then you know position i + 1 contains the initial you're looking for.

You must log in to answer this question.

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