Menu
CoddyTech

출력과 주석

Coddy의 Java 개발자를 위한 C 코스 레슨. 48개 중 2번째.

Java의 printf는 실행 시 형식 호환성을 검사합니다. C의 가변 인자 형식 지정에는 이러한 객체 유형 안전성이 없으므로, 승격된 인자 유형에 맞는 변환 지정자를 사용하세요.

인자 유형에 맞는 형식 지정자를 사용하세요. 출력 함수는 임의의 객체 형식을 추론하지 않습니다.

Java 예제


public class Main {

public static void main(String[] args) {
System.out.printf("value=%d%n",7);
}
}

Java 출력:

value=7

C 예제

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#include <stdbool.h>
#include <limits.h>
#include <errno.h>

int main(void) {
printf("value=%d\n",7);
return 0;
}

C 출력:

value=7
challenge icon

챌린지

쉬움

announce(value)를 구현하여 value= 뒤에 정수와 줄바꿈 문자 하나를 출력하세요. 입력은 정수 하나입니다.

잠금 해제된 소스 파일과 헤더 파일을 수정하세요. 표시된 잠금 상태의 main.c에서 직접 호출하므로 선언된 공개 API와의 호환성을 유지하세요. main을 추가로 만들지 마세요. 작업에서 범위를 명시적으로 확인하지 않는 한, 모든 숫자 작업 픽스처는 오버플로를 방지할 만큼 작습니다. 지정된 출력만 출력하세요. 표시된 경우 드라이버가 입력 파싱과 출력을 담당합니다.

직접 해보기

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#include <stdbool.h>
#include <limits.h>
#include <errno.h>
#include "lesson.h"
int main(void){int n=0;if(scanf("%d",&n)!=1)return 1;announce(n);return 0;}
quiz icon실력 점검

이 레슨에는 짧은 퀴즈가 포함되어 있습니다. 레슨을 시작해 문제를 풀고 진행 상황을 기록하세요.

Java 개발자를 위한 C의 모든 레슨

직접 연습해 보세요: 온라인 C 컴파일러