열렬히.뛰기

epur_str

école 42 > exam02 > exam02 : part3 > epur_str

공략법

  • while 돌기
    • while로 빈칸 뛰어넘고 ; start로 찾기
    • while로 빈칸 뛰어넘기 ; end 찾기
    • start와 end 이용해서 단어 출력
    • 공백 출력
  • 이후 코드 추가
    • 단어 출력공백 출력 사이에 while로 빈칸 찾기 추가
    • i번째 문자가 \0break ;

문제

Assignment name  : epur_str
Expected files   : epur_str.c
Allowed functions: write
--------------------------------------------------------------------------------

Write a program that takes a string, and displays this string with exactly one
space between words, with no spaces or tabs either at the beginning or the end,
followed by a \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
program displays \n.

Example:

$> ./epur_str "See? It's easy to print the same thing" | cat -e
See? It's easy to print the same thing$
$> ./epur_str " this        time it      will     be    more complex  . " | cat -e
this time it will be more complex .$
$> ./epur_str "No S*** Sherlock..." "nAw S*** ShErLaWQ..." | cat -e
$
$> ./epur_str "" | cat -e
$
$>