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.

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

Anyone know how to answer?


  • 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.

    #define BLANK 32

    int main()
    char ch ;

    while ((ch = getchar()) != '
    if (ch != BLANK)
    putchar(ch) ;
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!


In this Discussion