0

I have written this code to print first char and each subsequent char after "space" to be printed, but it is only printing first char what is the problem.

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

int main (void)

{
    printf ("Please enter full name: \n");

    string name=GetString();

    int lenth=strlen(name); 

    int i=0;

  for (i=0;i<lenth;i++)

  if (isspace(name[i]==1));//if isspace is equel to 1 or is true.
 { printf ("%c%c\n",name[0],name[i]+1);}//print first char and each cahr after isspace

}

1 Answer 1

0

Solved it. if isspace(name[i]) printf ("%c",name[i+1]); a silly mistake now working fine

You must log in to answer this question.

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