사전 프로세서 정보 - 1
예를 들어 아래의 화씨 회전 프로그램
/*
* celsius.c
*
* Created on: 2012-11-14
* Author: xiaobin
*/
#include <stdio.h>
#define FREEZING_PT (16.0 * \
2)
#define SCALE_FACTOR (5.0 / 9.0)
int main(void)
{
float fahrenheit, celsius;
printf("Enter Fahrenheit temperature: ");
scanf("%g", &fahrenheit);
printf("%g
", fahrenheit);
celsius = (fahrenheit - FREEZING_PT) * SCALE_FACTOR;
printf("Celsius equivalent is: %g", celsius);
return 0;
}
1. 사전 프로세서 줄 바꿈명령은 계속해야 한다는 명확한 지시가 없으면 항상 첫 번째 줄 바꾸기에서 끝난다.다음 줄에서 명령을 계속하려면 현재 줄의 끝에\문자를 사용해야 합니다.
#define FREEZING_PT 16.0 * \
2
2. 목록의 괄호 바꾸기가능한 한 작은 괄호를 사용하여 교체 목록을 묶어라, 이렇게 하면 읽기에 편리하다
3. 매개변수가 있는 사전 처리
상술한 프로그램은 프로그램의 처리 문장을 대체하기 위해 파라미터를 가진 사전 처리를 사용할 수 있다
#define FA2CE(f) ((f - FREEZING_PT) * SCALE_FACTOR)
첨부: 프로세서 프로그램 포함
/*
* celsius.c
*
* Created on: 2012-11-14
* Author: xiaobin
*/
#include <stdio.h>
#define FREEZING_PT (16.0 * \
2)
#define SCALE_FACTOR (5.0 / 9.0)
#define FA2CE(f) ((f - FREEZING_PT) * SCALE_FACTOR)
int main(void)
{
float fahrenheit, celsius;
printf("Enter Fahrenheit temperature: ");
scanf("%g", &fahrenheit);
printf("%g
", fahrenheit);
celsius = FA2CE(fahrenheit);
printf("Celsius equivalent is: %g", celsius);
return 0;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.