[C언어] 너무 사소해서 올리기 민망한 내용
1
#include <stdio.h>
int main(void)
{
int i = 0;
for (i = 0, printf("hello "); i < 5; ++i)
{
printf("%d ", i);
}
return 0;
}
output: hello 0 1 2 3 4
Reference: https://www.inflearn.com/course/following-c/dashboard
21/04/14 추가
#include <stdio.h>
int main()
{
int arr[4] = {1, 2, 3, 4, [1] = 4};
int i;
for (i = 0; i < 4; ++i)
{
printf("%d ", arr[i]);
}
}
output: 1 4 3 4
<designated initializer> 로 arr[1]의 값이 4로 덮어씌어졌다.
답변 2
0
자바 실험 결과
int i = 0;
for (System.out.println("hello "), i = 0; i < 3; i++) {
System.out.println("i = " + i);
}
output:
hello
i = 0
i = 1
i = 2
반복문 초기 값 선언에서 사용하는 변수를 for문 호출 전 선언 되어 있으면 가능,
아래와 같이 되어 있으면 컴파일 오류
for (System.out.println("hello "), int i = 0; i < 3; i++) {
System.out.println("i = " + i);
}





