Write a program to copy its input to output, replacing each each string of one or more balnks with a signle blank. This is C. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Write a program to copy its input to output, replacing each each string of one or more balnks with a signle blank. This is C.

Ive been using the while function, getchar and putchar. Im having trounle grasping the question though. Thanks

28th Apr 2017, 11:17 AM
Leo
Leo  - avatar
3 Answers
0
To get an entire line you can use fgets(), like so: char line [10]; fgets(&line, 10, stdin); then you can check if a string starts witb ' ', if so then on that position put a single ' ' and move on to the next string .
29th Apr 2017, 3:33 PM
José Pereira
José Pereira - avatar
0
So i end up doing manually ?
30th Apr 2017, 11:02 AM
Leo
Leo  - avatar
0
I mean...i dont think there is a function that does this so yes...and btw, while is a loop, not a function.
30th Apr 2017, 1:21 PM
José Pereira
José Pereira - avatar