TAILIEUCHUNG - C Programming for the Absolute Beginner phần 10

Tham khảo tài liệu 'c programming for the absolute beginner phần 10', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | C Programming for the Absolute Beginner Second Edition include define NUMBER 7 main printf nLucky Number d n NUMBER NUMBER 5 can not do this Attempting to change a symbolic constant s value will prevent your program from successfully compiling as Figure reveals. figure j Attempting to change the value of a symbolic constant generates a compiler error. Are Preprocessor Directives c Statements Preprocessor directives are actions performed before the compiler begins its job. Preprocessor directives act only to change the source program before the source code is compiled. The reason semicolons are not used is because they are not C statements and they are not executed during a program s execution. In the case of i ncl ude the preprocessor directive expands the source code so the compiler sees a much larger source program when it finally gets to do its job. Chapter 12 The C Preprocessor Creating and Using Macros Macros provide another interesting investigation into preprocessor text replacement. In fact C preprocessors treat macros similarly to symbolic constants they use text-replacement techniques and are created with the define statement. Macros provide a useful shortcut to tasks that are performed frequently. For example consider the following formula that computes the area of a rectangle. Area of a rectangle length x width If the area values of length and width were always 10 and 5 you could build a macro like this define AREA 10 5 In the real world however you know that this would be very limiting if not useless. Macros can play a greater role when built to use incoming and outgoing variables like a user-defined function would. When built in this way macros can save a C programmer keyboard time when using easily repeated statements. To demonstrate study the next program that improves the area of a rectangle formula. include define AREA l w l w main int length 0 int width 0 printf nEnter length scanf d length printf nEnter width scanf d .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.