Menu
CoddyTech

출력과 주석

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

Go의 fmt는 형식이 지정된 인수를 검사하고 출력 형식의 불일치를 보고합니다. C의 printf는 가변 인수 형식 계약을 신뢰하므로, 형식이 일치하지 않으면 정의되지 않은 동작이 발생할 수 있습니다.

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

Go 예제

package main
import ("fmt")

func main(){
fmt.Printf("value=%d\n",7)
}

Go 출력:

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실력 점검

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

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

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