강의

멘토링

커뮤니티

Inflearn Community Q&A

ylno19980817's profile image
ylno19980817

asked

C Programming - From Introduction to Game Development

for

for문에서의 ;

Written on

·

163

0

for 문 뒤에는 왜 ; 을 안넣나요?

c

Answer 1

1

';'은 어떤 문장이 끝났다는 것을 알려줍니다. 만약

for(i=1 ; i<=5 ; i++)

{

printf("*");

} 라고 코드를 입력한다면 의도대로 '*****'이 나타나겠지만,

for(i=1 ; i<=5 ; i++);

{

printf("*");

}

이라고 입력하면 for문은 저 ';' 때문에 아무것도 실행하지 않습니다.

세미콜론이 있기 때문에 밑에 있는 괄호는 이제 for문의 영역이 아닌 것입니다.

ylno19980817's profile image
ylno19980817

asked

Ask a question