블로그 이미지
Leeway is... the freedom that someone has to take the action they want to or to change their plans.
maetel

Notice

Recent Post

Recent Comment

Recent Trackback

Archive

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
  • total
  • today
  • yesterday

Category

Practical C Programming
http://www.oreilly.com/catalog/pcp3/

Chapter 4. Basic Declarations and Expressions


Basic Program Structure


The basic elements of a program are the data declarations, functions, and comments.

main() 함수는 첫번째로 호출되는 함수이며, 이 main 함수가 다른 함수들을 직접 또는 간접으로 호출한다.

return(0);는 프로그램이 정상적으로 (Status=0) 존재했었음을 OS에게 보고하기 위해 쓰인다. : return value가 클수록 error가 심각하다는 뜻이다.



Variables
Each variable has a variable type.
A variable must be defined in a declaration statement just before the main() line at the top of a program.

http://en.wikipedia.org/wiki/Computer_numbering_formats

http://en.wikipedia.org/wiki/Signed_number_representations



Assignment statements
The general form of the assignment statement is:
variable = expression;
The = is used for assignment.



printf Function

printf

: a standard function to output our message
Print formatted data to stdout
Writes to the standard output (stdout) a sequence of data formatted as the format argument specifies. After the format parameter, the function expects at least as many additional arguments as specified in format.
The format tags follow this prototype:
%[flags][width][.precision][length]specifier

: 표준 입출력 함수- 표준 입출력 장치를 통해 데이터를 입력하거나 출력하는 기능을 갖고 있는 함수
- 표준 입출력 함수를 사용하려면 #include <stdio.h>를 기술해 줘야 한다.
[형식] printf(" 출력양식 ", 인수1,인수2...);
- 서식문자열에는 모든 문자를 사용할 수 있으며 변환문자와 제어문자를 제외하고는 화면에 그대로 출력
- 인수와 변환문자는 일대일 대응해야 하며 반드시 인수의 자료형과 문자의 자료형은 일치해야 한다.
ex) printf("%d + %d= %d\n",10,20,30);
출력결과 10+20=30


stdout
Standard output stream
: the default destination of regular output for applications. It is usually directed to the output device of the standard console (generally, the screen).

cf. library fuctions


%d
: integer conversion specification

parameter list

The general form of the printf statement is:
printf(format, expression-1, expression-2, ...);
where format is the string describing what to point.



Characters

escape character


'@GSMC > 서용덕: DMD Programming' 카테고리의 다른 글

hw2  (0) 2008.03.15
week 2 review  (0) 2008.03.15
hw1  (0) 2008.03.10
Key concepts in programming: statement & expression  (1) 2008.03.09
week 1 review - keywords & file I/O  (0) 2008.03.07
posted by maetel