LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Exercise 1-9. Write a program to copy its input to its output, replacing each string (https://www.linuxquestions.org/questions/programming-9/exercise-1-9-write-a-program-to-copy-its-input-to-its-output-replacing-each-string-127717/)

zombi3 12-20-2003 10:55 PM

Exercise 1-9. Write a program to copy its input to its output, replacing each .......
 
Quote:

Exercise 1-9. Write a program to copy its input to its output, replacing each string of one or more blanks by a single blank.
If its possible can you guys give me tips on how to solve this questions.
Or if u can please show some sample code and try to example.

Luantum 12-21-2003 01:24 AM

So if the input is:
gsdgsdfg

dfsfsfgds



gdsfgsdafgdfg


the output is:
gsdgsdfg

dfsfsfgds

gdsfgsdafgdfg

Is that correct?

It seems like an easy thing to do. Grab stdin and use a for loop on it and put it into stdout.

Technoslave 12-21-2003 01:58 AM

See, i understood it as something like this:

Input:

Joe...is a schmoe that......everyone..knows. ( there really are spaces in here . <- is 1 space )

Output:

Joes is a schmoe that everyone knows.

In which case, using sed will fix up that problem easy.

zombi3 12-21-2003 02:28 AM

Thnx alot never knew this forum has such smart programming gurus


All times are GMT -5. The time now is 11:21 PM.