0

Not really sure where I'm messing up here. I've gone to several different questions in an attempt to answer this, and I'm getting nowhere. Here is the respective code down below.

int main(void)
{
      //gets name
      string n = GetString();

      //checks to make sure that the name entered is a string
      if (n != NULL)
      {
          //finds first initial (credit to Cliff B on CS50 Stack Exchange for helping me indirectly. Props to him)
          printf("%c\n", toupper(n[0]));
          //checks for second initial
          for (int i = 0; i < strlen(n); i++)
          {
            if isblank(n)
            {
               printf("%c\n", toupper(n[i+1]));
            }
          }
      }
}

Thanks in advance. If you'd like me to be more specific then I am right now, don't hesitate to ask. I've sort of been beating my head against a brick wall right now.

1
  • What error are you getting and where does it occur? – ronga Jun 17 '16 at 5:27
0

isblank() takes a character as an argument. You are providing it a string n.Thereby the segmentation fault. isblank(n[i]) will work

1
  • Thank you for your help. You saved me from a whole lot more head hitting. – jayfeather31 Jun 17 '16 at 16:47
0

As @VIGNESH said, isblank() takes character. Bit more

int isblank ( int c );

-> Checks if character is blank

-> Checks whether c is a blank character.

-> A blank character is a space character used to separate words within a line of text.

-> The standard "C" locale considers blank characters the tab character ('\t') and the space character (' ').

To your question:

 .
 .
 if isblank(n[i]) // n[i] instead of n. 
 {
     printf("%c\n", toupper(n[i+1]));
 }

You must log in to answer this question.

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