ABookOnC Chapter 1 - 1.3
이름: 나영철[삭제] [수정] 2001-01-21 04:13:52
Chapter 1

An Overview of C

This chapter gives an overview of the C Programming language. A series of programs is presented, and the elements of each program are carefully explained.

이 챕터는 C 프로그래밍언어의 개요를 보여준다. 프로그램들의 시리즈 하나가 소개되어지고, 각각의 프로그램의 요소들은 신중하게 설명되어진다.

Experimentation and interaction are emphasized throughout the text. In this chapter, we emphasize how to use the basic input/output functions of C.

실험과 작용은 text를 통해서 강조되어 진다.(그러니까 실제 compile 과 그것의 실행이 강조되어 진다.)
이 챕터에서 우리는 C의 기본 함수(input/output functions)들이 어떻게 사용되어지는지 강조한다.

Note carefully that all our C code also serves as C++ code and that all the ideas we discuss hold for c++ as well as for C. Of course, the C++ programmer has available a richer set of tools and techniques out of which programs can be constructed. (See Chapter 13, “Moving from C to C++.”)

신중하게 노트해라. 우리의 모든 C 코드는, C++ code 그리고 C와 마찬가지로 C++을 유지,보수(hold for) 하기 위해 논의하는 모든 아이디어들의 역할을,(구실을)(serve as) 또한 한다.
물론, C++프로그래머는 짜여질 수 있는 프로그램들의 밖에서,(외에) 풍부한 tools 과 techniques를 갖는 것이 가능하다.

Except for Section 1.8, “Arrays, Strings, and Pointers,” on page 36, everyone should read all the material in this chapter. Any reader who has had experience with arrays, pointers, and files in some other language can read all the sections of this chapter to get a more complete overview of C.

36page에 있는1.8장 “배열들, 스트링들, 포인터들,” 을 제외하고는, 모든 이들은 이 챕터의 모든 원료(자료,구성요소)를 읽어야만 한다.
어떤 독자들에게 있어서는, 그러니까 배열, 포인터, 파일에 대해서 어떤 다른 language안에서의 경험을 이미 가지고 있던 독자들은 C 의 개요를(overview of C) 더 완벽하게 얻기 위해서 이 챕터의 모든 작은 단원들을(sections) 읽을 수 있다.
(그러니까 배열, 포인터, 파일에 대한 경험이 있으면 1.8장 까지도 읽을 수 있는데, C를 처음 접하는 독자들은 최소한 1.8장을 제외한 다른 나머지 sections 을 모두 읽어야만 한다는 얘기인거 같습니다. ^_^)

Others can come back to material when they feel they are ready. Everyone should read this chapter with the understanding that technical details and further explanations will come in later chapter.

다른 이들은 그들이 준비가 되었다고 느낄 때 다시 원료,(내용으)(material)로 돌아 올 수 있다.
(이 내용 또한 1.8장을 그냥 넘어간 독자들이 나중에 배열과, 포인터, 파일 등에 대해서 어느 정도 알고
난 다음에 1.8장으로 다시 돌아와 내용을 볼 수 있다는 얘기입니다.)
모든 이들은 기술적인 세부사항과 더 많은 설명들이 다음 챕터에서 계속 된다(will come)는 이해와 더불어 본 챕터를 읽어야 할 것이다.

1.1 Programming and preparation

Resident on the machine is a collection of special programs called the operating system. Commonly available operating systems include MS-DOS. OS/2, and UNIX. An operating system manages machine resources, provides software for the user, and acts as an interface between the user and hardware.

머신위에 존재하는(살아가는, Resident) 특별한 프로그램들의 집합체를 운영체제(operating system) 라 부른다. 일반적으로 가능한 운영체제는 MS-DOS, OS/2, and UNIX를 포함한다(일컫는다). 하나의 운영체제는 머신의 자원들을 관리하고, 사용자를 위한 소프트웨어와 그리고 사용자와 하드웨어의 사이를 연결하는(조정하는,interface)행위들을 제공한다(사용자와 하드웨어 사이의 interface를 제공한다).

Among the many software packages provided by the operating system are the C compiler and various text editors. The principal text editor on the UNIX system is called vi. Some systems, such as Borland C++, integrate the text editor and the compiler.

운영체제(Operating system)에 의해서 제공되어지는 많은 소프트웨어 팩키지들 중에는 C compiler 와 다양한 문서편집기(text editor)가 있다. UNIX system에서의 주된 문서 편집기는 vi 라 불린다. Borland C++ 과 같은 어떤 시스템들은 문서편집기와 compiler를 통합하고 있다.

We assume that the reader is able to use some text editor to create files containing C code. Such files are called source files, and they are compiled on most UNIX system with the cc command, which invokes the C compiler. Because the cc command invokes the compiler, the name of the command is also the name of the compiler. Thus, C compiler and cc compiler are used interchangeably. Roughly speaking, a compiler translates source code to object code that is executable.

우리는 가정한다. 독자들이 C code를 포함하고 있는 파일을 생성하기 위한 어떤 문서 편집기를 사용할 수 있다는 것을. 그러한 파일들을 source파일 이라 하고, 그들은 대부분의 UNIX system에서cc 라는 명령으로 compile 되어진다. cc 라는 명령은 C compiler를 불러들인다. cc 라는 명령어가 컴파일러를 불러들이기 때문에, 명령어의 이름은 또한 컴파일러의 이름이다. 그러므로, C compiler 와 cc compiler 는 교환하여(같은 의미로) 사용 되어 졌다. 거칠게 말하자면, 컴파일러는 source code를 실행할 수 있는object code로 변환시켜주는 것이다.

On UNIX systems, this compiled code is automatically created in a file named a.out.
On MS-DOS systems, this compiled code is automatically created in a file with the same name as the .c file, but with the .exe extension replacing the .c extension. At the end of this chapter, in Section 1.10, “Operating System Considerations,” on page 53, we present in detail the steps necessary to edit, compile, and execute a program.

UNIX system에서는 이 컴파일된 코드가a.out이라는 파일 이름 안에 자동적으로 만들어진다.(컴파일 하면 그 파일 이름이 a.out이 된다.)
MS-DOS system에서는 이렇게 compile 된 코드가 .c 파일과 같은 이름으로 창조되어 진다. 단지 .c 확장자가 .exe 확장자로 교체되면서. (도스에서는 poem.c 라는 소스 코드를 컴파일 하면 poem.exe 라는 실행 파일이 만들어지는데 뒤에 있는 확장자(.c -> .exe로)만 바뀌면서 앞의 ‘poem’이라는 이름은 그대로 유지 된다는 것이다.)
이 챕터의 마지막 부분, Section 1.10안의, 53page에 있는”Operating System Considerations”(운영체제의 고찰)에서 우리는 프로그램의 편집, 컴파일, 그리고 실행하기위해 필요한 세부적인 과정들을 소개한다.

1.2 Program Output

Programs must communicate to be useful. Our first example is a program that prints on the screen the phrase “from sea to shining C.” The complete program is

프로그램들은 유용함을(써먹기)위해 전달(communicate) 되어야 한다. 우리의 첫번째 예는 스크린에 “from sea to shining C.” 라는 문구를 프린트하는 프로그램이다. 완성된 프로그램은 In file sea.c 에 있다.

In file sea.c

#include

int main(void)
{
printf(“from sea to shining C\n”);
return 0;
}

Using a text editor, we type this into a file whose name ends in .c. The choice of a file name should be mnemonic. Let us suppose the program has been written in the file sea.c. To compile the program, we give the command

문서 편집기(text editor)를 사용하여, 우리는 그 파일의 이름의 끝이 .c 인 파일 안에 이것(위에 있는 source code)을 써 넣는다. 파일 이름의 선택은 기억하기 쉬운 것으로 한다. sea.c 라는 파일 안에 프로그램이 쓰여졌다고 가정해 보자. 그 프로그램을 컴파일 하기 위해 우리는 명령을 준다.

cc sea.c

If there are no errors in the code, the executable file a.out is created by this command.
Now the command

만약 코드 안에 아무런 에러가 없다면, 이 명령(위에 쓴 cc sea.c)에 의해 실행 가능한 파일 a.out이 만들어 진다.
이제 명령 a.out 은

a. out

executes the program and prints on the screen
프로그램을 실행하고(다음 내용을) 스크린 위에 프린트 한다.

from sea to shining C

Dissection of the sea Program (프로그램 sea의 해부)

#include

A preprocessor is built into the C compiler. When the command to compile a program is given, the code is first preprocessed and then compiled. Lines that begin with a # communicate with the preprocessed. This #include line causes the preprocessor to include a copy of the header file at this point in the code.
This header file is provided by the C system. The angle brackets around indicate that the file is to be found in the usual place, which is system-dependent. We have included this file because it contains information about the printf() function.

Preprocessor(전처리 장치, 미리 분석하는 장치: 저의 번역에서는 preprocessor를 그냥 고유 명사화 해서 사용할 것입니다. ‘전처리 장치’라는 단어보다 preprocessor라는 단어가 더 낫다고 생각합니다. 앞으로도 몇 개 정도는 고유 명사화 해서 사용하는 단어들이 있을 겁니다.)는 C 컴파일러에 의해(C 컴파일러를 써서) 조립되어 졌다(만들어 졌다, is built into).
#과 함께 시작하는 줄(문장)들은 미리 분석되어서(전처리 되어서,preprocessed) 전달(의사소통, 통신)된다.
이 #include 라인은 (preprocessor를 이용해) 코드 안의 이 부분, 즉 헤더 파일인 의 하나의 카피(복제,a copy)를 불러들이기(to include)위해 preprocessor를 일으킨다.
(개인적인 해설: # include 라인은 라는 헤더 파일을 불러 들이는데(복사 하는데) 그렇게 하기 위해서 미리 분석하는 장치인 preprocessor를 일으킨다는(causes) 혹은 사용한다는 이야기 입니다. 그럼 왜 헤더파일을 불러 들여야 하나요? 컴파일러가 인간의 source code를 기계어로 바꾸어주어 0과 1,(전류가 흐르냐 흐르지 않느냐)밖에 알 수 없는machine 에게 인식하도록 해주는 것이라는 것이라고 생각 할 때 그 중간에 어떠한 연결 고리가 있어야 하겠지요? 혹은 아주 기본이 되는 함수들이 있어야 하지 않을까요? 0과 1에 가깝거나 혹은 그것들에 접근할 수 있는 기본적인 함수들 말이죠. 물론 조금 응용된 함수들도 있겠지요. 뭐 꼭 이러한 것이 헤더파일의 정의는 아니겠지만 왜 헤더파일을 불러들여야만 하는가에 대한 궁금증 정도가 풀리는 데에는 도움이 될 것 같습니다.)

int main(void)

This is the first line of the function definition for main(). (We write parentheses after the name main to remind the reader that main() is a function.) The two words int and void are keywords, also called reserved words. They have special meaning to the compiler. In Section 2.4, “Keywords,” on page77, we will see that there are 32 keywords in C, including int and void.

이것은 main()함수를 위한 함수정의의 첫번째 라인이다. (우리는 main()이 함수라는 것을 읽는 이에게 상기시키기 위해 main이라는 이름 뒤에 괄호(parenthesis)를 쓴다.) 두 단어 int 와 void는 keywords(이것 또한 고유명사로 쓰겠습니다.)이다. 또한 예약된(훗날을 위해 떼어 놓은, reserved) 단어들이라고도 부른다. 그들은 컴파일러에게 특별한 의미를 지닌다. 77page에 In Section 2.4, “keywords,” 에서, 우리는 C 안에서의 32개의 keywords를 볼 것이다, int 와 void 를 포함하여.

int main(void)
{
....

Every program has function named main(). Program execution always starts with this function. The top line should be read as “main() is a function that takes no arguments and return an int value.”

모든 프로그램은 main()이라는 이름의 함수를 갖는다. 프로그램의 실행은 항상 이 함수와 함께 시작한다. 제일 위의 라인은 “main()은 어떤 독립변수(arguments) 들도 취하지 않으며 int value를 되돌린다” 라고 읽혀져야 한다.

Here, the keyword int tells the compiler that this function returns a value of type int. The word int stands for integer, but the word integer itself cannot be used. The parentheses following main indicate to the compiler that main is a function.

여기, 키워드 int 는 컴파일러에게 이 함수는 int 형(int type)의 값을 되돌린다고 얘기한다. int 라는 단어는 정수(integer)를 의미하지만(integer 의 약자이지만), integer라는 단어는 그 스스로 사용되어 질 수 없다. main 함수 뒤에오는 괄호() 는 컴파일러에게 main은 함수라는 것을 가리킨다.

This idea is confusing at first because what you see following main is (void), but only the parentheses () constitute an operator telling the compiler that main is a function. The keyword void indicates to the compiler that this function takes no arguments. When we write about functions such as main() and printf(), we usually follow the name in print with parentheses. This indicates to the reader that we are discussing a function. (Many programming books follow this practice.)

이 형태(외관,idea)는 main뒤에 따르는 (void) 를 당신이 보는 이유로 처음에 혼란스럽다.
하지만 단지 괄호는 main은 함수라고 컴파일러에게 얘기해주는 연산자(operator)를 구성한다. 키워드 void 는, 어떠한 독립변수(arguments) 들도 취하지 않는 이 함수를 컴파일러에게 인식케 한다. (그러니까 int main(void)에서 void는 이 함수가 어떠한 독립변수도 취하지 않는다는 것을 가리킨다는 것이다. 우리가 main() 과 printf()와 같은 함수들에 대해 쓸 때, 우리는 일반적으로 괄호와 함께 쓰인 이름들을 따른다. (이 문장은 아주 재밌는 문장인데 그러니까 함수들을 쓸 때 main() , printf() 이런 식으로 괄호와 함께 쓴다는 내용입니다.) 이것은 독자들에게 우리가 함수에 대해 논의하고 있다는 것을 가리킨다.
(많은 프로그래밍 책들이 이러한 습관(관례)을 따른다.)

{

Braces surround the body of a function definition. They are also used to group statement together.
중괄호는 함수정의의 몸을 묶는다. 그들은 또한 문장 그룹으로 함께 사용되어진다.

printf()

The C system contains a standard library of functions that can be used in programs.
This is a function from the library that prints on the screen. We included the header file stdio.h because it provides certain information to the compiler about the function printf().

C system은 프로그램들이 사용되어질 수 있는 함수들의 표준 라이브러리를 포함한다. 이 함수는 스크린 위에 프린트 되어지는 라이브러리 함수이다. 우리는 헤더파일 stdio.h를 포함시켰다. 이유는 그것은 printf()함수에 대한 확실한 정보를 컴파일러에게 제공하기 때문에.

“from sea to shining C\n”

A string constant in C is a series of characters surrounded by double quotes. This string is an argument to the function printf(), and it controls what gets printed. The two characters \n at the end of the string(read backslash n) represent a single character called newline. It is a nonprinting character. It advances the cursor on the screen to the beginning of the next line.

C 안에서의 문자열 상수(string constant)는 따옴표에 의해 둘러싸여진 문자들의 한 시리즈다.
이 문자열은 printf() 함수의 한 독립변수(고정변수, argument)이다. 그리고 그것은 무엇이 프린트 되어질지 콘트롤 한다. 문자열의 끝에 있는 두 문자들 \n (“backslash n” 이라고 읽는다)은 새로운 줄(newline)이라 불리는 하나의 독자성을 가진(순수한,single) 문자를 나타낸다. 그것은 찍히지 않는 문자이다. 그것은 스크린 위의 커서를 다음 라인의 시작부분에 진보(위치)시킨다.

Printf(“from sea to shining C\n”);

This is statement. Many statements in C end with a semicolon.
이것은 진술이다(문장이다). C안에서 많은 문장(진술, statements)들의 끝은 세미콜론과 함께한다. (C 언어에서는 문장의 끝엔 세미콜론 semicolon 을 쓴다는 얘기입니다.)

return 0;

This is a return statement. It causes the value zero to be returned to the operating system, which in turn may use the value in some way, but is not required to do so.
(See Section 12.7, “Returning the Status,” on page 579, for further discussion.)

이것은 리턴 문이다. 이것은 운영체제에게 영의 값을 되돌려 받는 원인이 된다. 운영체제는 어떤 경로(경우, 방법)에 있어서는 돌려 받는 값이 사용되어 질 수도 있지만, 하지만 그렇게 하기위해 요구되어지지는 않는다. (값을 돌려 받을 수도 아닐 수도 있다.)

Our use of this return statement keeps the compiler happy. If we do not use it, the compiler will complain.(See exercise 4, on page 60.) One of the principal rules of programming is “keep your compiler happy.”

이러한 리턴 문의 쓰임새는 컴파일러를 행복하게 유지해준다. 만약 우리가 이것을 사용하지 않는다면, 컴파일러는 불평을 할 것이다. 프로그래밍의 근본적인 법칙은 “컴파일러를 행복하게 해라.” 이다.

}

The right brace matches the left brace above, ending the function definition for main().
오른쪽 중괄호는 앞에 있던 왼쪽의 중괄호와 매치되고, main()을 위한 함수정의의 종결이다.


+ + + + + + +

The function printf() acts to print continuously across the screen. It moves the cursor to the start of a new line when a newline character is read. The screen is a two-dimensional display that prints from left to right and top to bottom. To be readable, output must appear properly spaced on the screen.
We can rewrite our first program as follows:

함수 printf()는 스크린을 지속적으로 가로지르는 프린트를 하기 위해 실행한다. 그것은 newline(\n) 문자가 읽혀 졌을 때 새로운 줄의 시작에 커서를 갖다 놓는다. 스크린은 2차원의, 그러니까 왼쪽에서부터 오른쪽으로 그리고 위에서부터 아래로 프린트하는 dispaly이다. 읽을 수 있게 하기 위해, 출력(output)은 스크린 위에 적절한 공간을 나타내어야 한다.
우리는 우리의 첫번째 프로그램을 다음과 같이 다시 쓸 수 있다.

#include

int main(void)
{
printf(“from sea to “);
printf(“shining C”);
printf(“\n”);
return 0;
}

Although it is different from the first version, it will produce the same output. Each time printf()is called, printing begins at the position where the previous call to printf() left off. If we want to print our phrase on three lines, we can use newline characters.

비록 첫번째 버전과는 다르지만, 그것은 같은 출력(output)을 만들어 낼 것이다. printf()함수는 매번 불려지고, 이전에 왼쪽에서 끝난 printf()함수를 부른 그 장소에서부터 프린트는 시작된다. 만약 우리가 세개의 줄 위에 우리의 이야기를(구,phrase) 프린트하고 싶다면, 우리는 newline (\n) 문자를 사용할 수 있다.

#include

int main(void)
{
printf(“from sea\n”);
printf(“to shining\nC\n”);
return 0;
}

When executed, this program will print
프로그램이 실행되어 졌을 때, 이 프로그램은 다음처럼 프린트 할 것이다.

from sea
to shining
C

Let us write one additional on this program, one that will box the phrase in a rectangle of asterisks. It will show how each character, including blanks and newline characters, is significant, and when it is executed, it will give some sense of the screen proportions.

이 프로그램위에 하나를 덧붙여 써보자, 그 하나란 아스테리스크(*)들에 의한 사각형 안의 박스 이야기(구,phrase)가 될것이다. 그것이 실행 되었을 때 빈 칸들과 newline(\n)문자를 포함하는 각각의 문자들을 보여줄 것이다. 그것은 중요한 것이고, 그것은 스크린의 비율(균형,proportions)의 어떤 감각을 주게 될 것이다.

In file sea2.c

#include

int main(void)
{
printf(“\n\n\n\n\n\n\n\n\n\n”);
printf(“              **********************\n”);
printf(“              *   from sea                  *\n”);
printf(“              * to shining C               *\n”);
printf(“              **********************\n”);
printf(“\n\n\n\n\n\n\n\n\n\n”);


return 0;
}

1.3 Variables, Expressions, and Assignment

We will write a program to convert the distance of a marathon in miles and yards to kilometers. In English units, a marathon is defined to be 26 miles and 385 yards. These numbers are integers.

우리는 miles과 yards의 마라톤의 거리를 kilometers로 변환시킬 것이다. 영국의 단위에서는, 마라톤은 26마일 385야드로 정의되어 있다. 이러한 수들은 정수들이다.

To convert miles to kilometers, we multiply by the conversion factor 1.609, a real number. In memory, computers represent integers differently from real. To convert yards to miles, we divide by 1760.0, and, as we shell see, it is essential to represent this number as a real rather as an integer.

Miles를 kilometers로 변화 시키기 위해서, 우리는 실수인 변환 인자 1.609에 의한 곱셈을 한다. 메모리에서, 컴퓨터들은 실수와 정수를 다른 것으로 표현한다. yards를 miles로 변환시키기 위해서, 1760.0으로 나누고, 그리고, 우리가 보는 바와 같이, 이 숫자를 나타내는 데에는 정수보다는 실수가 필요하다.(실질적이다.)

Our conversion program will use variables capable of strong integer values and real values.

우리의 변환 프로그램은 정수형 값과 실수형 값의 변수들을 사용할 것이다.
In C, all variables must be declared, or named, at the beginning of the program. A variable name, also called an identifier, consists of a sequence of letters, digits, and underscores, but may not start with a digit.

C에서는, 모든 변수들이 그 프로그램이 시작되어 질 때 선언되어지거나 이름 지어진다. 변수의 이름은, 또한 identifier(확인자)라고 불리며, 숫자로 시작하지는 않는 문자들의 열과 숫자들, 그리고 밑줄에 의해 구성되어진다.

Identifiers should be chosen to reflect their use in the program. In this way, they serve as documentation, making the program more readable.

확인자들(변수들)은 프로그램에서 그들의 쓰임을 반향하기 위해서 선택되어 져야 한다. 이런 방법으로, 그들은 만드는 프로그램을 문서처럼 더 읽을 수 있게 해준다.

In file marathon.c

/* The distance of a marathon in kilometers */
#include

int main(void)
{
int    miles, yards;
float    kilometers;

miles = 26;
yards = 385;
kilometers = 1.609 * (miles + yards / 1760.0);
printf(“\nA marathin is %f kilometers. \n\n”, kilometers);
return 0;
}

The output of the program is

A marathon is 42.185970 kilometers.

Dissection of the marathon Program

/* The distance of a marathon in kilometers. */

Anything written between the characters /* and */ is a comment and is ignored by the compiler. All programs in this book that start with a comment are listed in the index.

문자들 /* 과 */들 사이에 쓰여진 어떤 것들도 주석,해설,설명이며 컴파일러에의해 무시당한다. 이 책 안에서의 모든 프로그램들은 index안에서 list 되어진 주석문과 함께 시작한다.

int    miles, yards;

This is a declaration. Declarations and statements end with a semicolon. int is a keyword and is one of the fundamental types of the language. It informs the compiler that the variables flowing it are type int and are to take on integer values. Thus, the variables miles and yards in this program are of type int.

이것은 선언이다. 선언들과 문장들은 세미콜론과 함께 끝난다. int 는 키워드(keyword)이며 언어의 기본적인 형(types)들 중의 하나이다. 그것은 컴파일러에게 변수들이 int 형을 따른다는 것과 정수형의 값들을 취하기 위한 것임을 알려준다. 그러므로, 프로그램 안에서 miles와 yards라는 변수들은 int 형이다.

float    kilometers;

This is a declaration. float is a keyword and is one of the fundamental types of the language. It informs the compiler that the variables following it are of type float and are to take on real values. Thus, the variable kilometers in this program is of type float.

이것은 선언이다. float 는 키워드(keyword)이고 언어의 기본적인 형(types)들중의 하나이다. 그것은 컴파일러에게 알려준다. 변수들이 float형을 따르고 실수의 값들을 취한다는 것을. 그러므로, 프로그램에서 변수 kilometers 는 float형이다.

miles = 26;
yards = 385;

These are assignment statements. The equal sign is an assignment operator. The two numbers 26 and 385 are integer constants. The value 26 is assigned to the variable miles. The value 385 is assigned to the variable yards.

이것들은 할당 문들이다. 이퀄 기호는 할당 연산자이다. 두개의 숫자들 26과 385는 정수 상수들이다. 값 26은 변수 miles에 할당되어 진다. 값 385는 변수 yards에 할당되어 진다.

Kilometers = 1.609 * (miles + yards / 1760.0);

This is assignment statement. The value of the expression on the right side of the equal sign is assigned to the variable kilometers. The operator *, +, and / stand for multiplication, addition, and division, respectively. Operations inside parentheses are performed first. Because division has higher precedence than addition, the value of the sub expression

이것은 할당문이다. 이퀄 기호의 오른쪽편에 있는 표현 값은 변수 kilometers에 할당되어 진다. 연산자  *, +, 그리고 / 은 제각각 곱셈, 덧셈, 나눗셈의 약칭,약자,대신해서 쓰이는 것(stand for)이다. ()괄호 안에 있는 연산자들은 첫번째로 수행되어 진다. 나눗셈은 덧셈보다 높은 우선순위를 갖기 때문에, 하위 표현(subexpression)값 yards / 1760.0

yards / 1760.0

is calculated first. (See Appendix E, “Operator precedence and Associativity.”) That value is added to the value of the variable miles to produce a value that is then multiplied by 1.609. This final value is then assigned to the variable kilometers.

은 먼저 계산되어 진다. 그 값은 그리고나서 1.609에 의해 곱하여진 값을 산출하기 위해 변수 miles의 값에 더하여 진다. 마지막 값은 그리고 나서 변수 kilometers에 할당되어 진다.

printf(“\nA marathon is %f kilometers.\n\n”, kilometers);

This is a statement that invokes, or calls, the printf() function. The function printf() can have a variable number of arguments. The first argument is always a string, called the control string. The control string in this example is

이 문장은 printf()함수를 가져오거나 불러낸다. 함수 printf()는 독립변수들의 변수 숫자를(그냥 변수를이라고 해석하는 것이 더 좋을 듯,a variable number) 가질 수 있다. 첫번째 고정변수는 control string이라 불리는 하나의 문자열이다. 이 예에서 control string은 아래와 같다.


“\nA marathon is %f kilometers. \n\n”

It is the first argument to the function printf(). Inside this string is the conversion specification, or format, %f. The formats in a control string, if any, are matched with the remaining arguments in the printf() function.

이것은 printf()함수를 향하는 첫번째 고정변수이다. 이 문자열 안에는 전환,변환사항(conversion specification), 혹은 형식이 되는 %f 가 있다. control string 안에서의 형식은(conversion specification, format, 예를들면 이 문장에서 %f는), 만약 있다면, printf()함수 안에서의 남아있는 고정변수들과 함께 어울린다.

In this case, %f is matched with the argument kilometers. Its effect is to print the value of the variable kilometers as a floating-point number and insert it into the print stream where the format %f occurs.

이 경우에서는, %f는 고정변수 kilometers와 함께 짝이 된다.(어울린다). 그것의 결과는, floating-point number 와 format %f가 발생하여 print stream 안으로 그것을(floating-point number를) 집어넣는, 변수 kilometers의 값을 프린트한다.
  이 름  암 호  보안코드  
번호작성자날짜조회제    목
77onion2001-02-023042   [잡담] Counter이상 있는거 아닙니까...? (3)
76onion2001-02-023038   [잡담] 하웅......퇴근해야지....
75onion2001-02-012845   [잡담] 햐아..밤새버렸습니다...후훗..
74onion2001-01-302817   [잡담] 대문이 바뀌었다아... (4)
73GoodWolf2001-01-293603   NeXT에서 아파치랑 php랑 MysQL..어떻게 하나여?? (1)
72최승희2001-01-294824   야동 가는길.... 그것이 200m나 ??
71나영철2001-01-213911   ABookOnC 를 올린 이유
70나영철2001-01-213562   ABookOnC Chapter 6 - 6.2 Source code 까지
69나영철2001-01-213229   ABookOnC Chapter 5 - 5.4
68나영철2001-01-214356   ABookOnC Chapter 1 - 1.3
67onion2001-01-162969   [잡담] 아이 XX팔려라....캬캬캬...
66최승희2001-01-163007   심각한 고민..이걸 어떻게 풀어야 하지? (1)
65나영철2001-01-162944   왜 제 글에 대한 답은 안해주시나요?? (1)
64onion2001-01-153367   [잡담] 간단하게 한글 사용법을 제 홈에 올렸습니다.. (1)
63onion2001-01-143939   [질문] openstep 에서 한글이요... (11)
[≪] [<] [51] [52] [53] [54] [55] [56] [57] [58] [59] [60]