It may seem easy but anyone know how to slove it?

Q: Write a C program that reads a string from keyboard and displays the input string with all blanks removed.

#include
#include
#include
#define c 81
int main(void)
{
char input[c];
int i; /*using one control variable only*/
clrscr();
printf("Enter a string and press key:
");
scanf(" %[^
]", input);
for(i = 0; input[i]; ++i)
{
if(isspace(input[i])
{
???????? /*What code should be fill here?*/
}
}
printf("The modified string is:
%s", input);
if(!getch()) getch();
return 0;
}


Anyone know how to answer?

Comments

  • This is my take on it. Hopefully, it's self explanatory. Sorry, but I have not compiled and tested it. I've been up all night and I need sleep. I'll check back later.

    [code]
    #include
    #define BLANK 32

    int main()
    {
    char ch ;

    while ((ch = getchar()) != '
    ')
    if (ch != BLANK)
    putchar(ch) ;
    }
    [/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion