로그인 바로가기 하위 메뉴 바로가기 본문 바로가기
난이도
입문

모두를 위한 컴퓨터 과학 (CS50 2019)

임시 이미지 David J. Malan (데이비드 J. 말란)
http://www.boostcourse.org/cs112/forum/130333
좋아요 15203 수강생 32899

여기서 마지막 줄에 return n을 해주면서 n 값을 get_postive_int 함수에 저장을 해주는건가요?

#include <cs50.h>
#include <stdio.h>

int get_positive_int(void);

int main(void)
{
    int i = get_positive_int();
    printf("%i\n", i);
}

int get_positive_int(void)
{
    int n;
    do
    {
        n = get_int("Positive Integer: ");
    }
    while (n < 1);
    return n;
}