소개글
UNIX의 FMT를 구현한 프로그램 입니다.텍스트파일을 읽어와서 일정한 룰을 적용한 텍스트파일로 변환합니다.
이 프로그램의 기본 동작을 설명하기 위해 예제를 먼저 입력하자면
INPUT--------------------------------------------------------
Unix fmt
The unix fmt program reads lines of text, combining
and breaking lines so as to create an
output file with lines as close to without exceeding
72 characters long as possible. The rules for combining and breaking
lines are as follows.
1. A new line may be started anywhere there is a space in the input.
If a new line is started, there will be no trailing blanks at the
end of the previous line or at the beginning of the new line.
2. A line break in the input may be eliminated in the output, provided
it is not followed by a space or another line break. If a line
break is eliminated, it is replaced by a space.
OUTPUT--------------------------------------------------------------
Unix fmt
The unix fmt program reads lines of text, combining and breaking lines so
as to create an output file with lines as close to without exceeding 72
characters long as possible. The rules for combining and breaking lines
are as follows.
1. A new line may be started anywhere there is a space in the input.
If a new line is started, there will be no trailing blanks at the end of
the previous line or at the beginning of the new line.
2. A line break in the input may be eliminated in the output,
provided it is not followed by a space or another line break. If a line
break is eliminated, it is replaced by a space.
--------------------------------------------------------------------------
법칙들-
1. 한둘의 길이는 공백을 포함해서 최대 72자이며, 이를 넘어갈 경우 단어 단위로 다음줄로
내린다. 만약 72자가 안되며, 다음줄의 단어들을 포함해서도 72자가 넘지 않으면 넘기
직전까지 계속 단어를 위로 끌어 올린다.
2. 연속된 줄바꿈은 원칙적으로 보존한다.
3. 단어의 앞부분에 있는 연속된 space또한 유지한다.
4. 단어를 올리거나 내릴때에는 space와 줄바꿈은 1개의 space로 대체될수 있다.
프로그램된 방법은, 단어를 인식하기 위해서 2개의 character 를 읽어와서
그것이 단어의 중간에 있는 2글자인지, 단어의 끝을 포함하는지, 단어의 시작인지,
로 크게 분류하여 처리합니다.
ps. 만드는데 상당히 힘들었습니다..
컴파일 실행환경
비쥬얼 스튜디오 2003윈도우 XP 32비트
소스파일, 프로젝트파일, DEBUG모드로 컴파일된 실행파일 포함.
압축파일 내 파일목록
FMT.c
FMT.ncb
FMT.rar
FMT.sln
FMT.suo
FMT.vcproj
input2.txt
input3.txt
Input.txt
output.txt
Debug/BuildLog.htm
Debug/Debug.rar
Debug/FMT.exe
Debug/FMT.ilk
Debug/FMT.obj
Debug/FMT.pdb
Debug/i.txt
Debug/i2.txt
Debug/Input.txt
Debug/input2.txt
Debug/input3.txt
Debug/o2.txt
Debug/output.txt
Debug/output2.txt
Debug/vc70.idb
Debug/vc70.pdb
Debug/7.txt
FMT.ncb
FMT.rar
FMT.sln
FMT.suo
FMT.vcproj
input2.txt
input3.txt
Input.txt
output.txt
Debug/BuildLog.htm
Debug/Debug.rar
Debug/FMT.exe
Debug/FMT.ilk
Debug/FMT.obj
Debug/FMT.pdb
Debug/i.txt
Debug/i2.txt
Debug/Input.txt
Debug/input2.txt
Debug/input3.txt
Debug/o2.txt
Debug/output.txt
Debug/output2.txt
Debug/vc70.idb
Debug/vc70.pdb
Debug/7.txt