강의

멘토링

커뮤니티

Inflearn Community Q&A

lovefor8892842's profile image
lovefor8892842

asked

Everything You Need to Know About C Language from the Author of Self-Study C Language

7.2 - Different types of functions

반환값이 없는 함수 사용에 대하여

Written on

·

438

0

반환값이 없는 함수에 나온 예제를 그대로 실행시켜봤는데

#include<stdio.h>

void print_char(char ch, int cnt)

{

int i;

for (i = 0; i < cnt; i++);

printf("%c", ch);

}

int main()

{

print_char('*', 5);

}

코드를 실행시켰습니다.

근데 결과물이 *****이 나와야할거같은데

결과가 * 하나만 나와요 뭐가 잘못된건가요?

c

Answer 1

0

print_char 함수에서 for(i=0;i<cnt;i++);에서 ;를 빼야 합니다

lovefor8892842's profile image
lovefor8892842

asked

Ask a question