|
|
|
## cleanstr
|
|
|
|
|
|
|
|
### Instructions
|
|
|
|
|
|
|
|
Write a **program** that takes a `string`, and displays this `string` with exactly:
|
|
|
|
|
|
|
|
- one space between words.
|
|
|
|
- without spaces nor tabs at the beginning nor at the end.
|
|
|
|
- with the result followed by a newline ("`\n`").
|
|
|
|
|
|
|
|
A "word" is defined as a part of a `string` delimited either by spaces/tabs, or
|
|
|
|
by the start/end of the `string`.
|
|
|
|
|
|
|
|
If the number of arguments is not 1, or if there are no words to display, the
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
program displays nothing.
|
|
|
|
|
|
|
|
### Usage :
|
|
|
|
|
|
|
|
```console
|
|
|
|
student@ubuntu:~/[[ROOT]]/cleanstr$ go build
|
|
|
|
student@ubuntu:~/[[ROOT]]/cleanstr$ ./cleanstr "you see it's easy to display the same thing" | cat -e
|
|
|
|
you see it's easy to display the same thing$
|
|
|
|
student@ubuntu:~/[[ROOT]]/cleanstr$ ./cleanstr " only it's harder "
|
|
|
|
only it's harder$
|
|
|
|
student@ubuntu:~/[[ROOT]]/cleanstr$ ./cleanstr " how funny" "Did you hear Mathilde ?"
|
|
|
|
$
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
student@ubuntu:~/[[ROOT]]/cleanstr$ ./cleanstr ""
|
|
|
|
student@ubuntu:~/[[ROOT]]/cleanstr$
|
|
|
|
```
|