공략법
while돌기while로 빈칸 뛰어넘고 ; start로 찾기while로 빈칸 뛰어넘기 ; end 찾기- 단어 출력
- 공백 출력
- 이후 코드 추가
- 단어 출력과 공백 출력 사이에
while로 빈칸 찾기 추가 - i번째 문자가
\0면break ;
- 단어 출력과 공백 출력 사이에
왜? " this time it will be more complex " 와 같은 예시를 보자.
- complex까지 출력하고 해당 부분을 넣어주면 알아서 공백까지 간다.
- 그러면 complex 이후에 아무 것도 출력되지 않게 된다.
문제
c
Assignment name : expand_str
Expected files : expand_str.c
Allowed functions: write
--------------------------------------------------------------------------------
Write a program that takes a string and displays it with exactly three spaces
between each word, with no spaces or tabs either at the beginning or the end,
followed by a newline.
A word is a section of string delimited either by spaces/tabs, or by the
start/end of the string.
If the number of parameters is not 1, or if there are no words, simply display
a newline.
Examples:
$> ./expand_str "See? It's easy to print the same thing" | cat -e
See? It's easy to print the same thing$
$> ./expand_str " this time it will be more complex " | cat -e
this time it will be more complex$
$> ./expand_str "No S*** Sherlock..." "nAw S*** ShErLaWQ..." | cat -e
$
$> ./expand_str "" | cat -e
$
$>