Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 따배씨
- Cleancode
- dfs
- php
- JavaScript
- programmers
- 따라하며 배우는 C언어
- sorting
- C
- graph
- 생활코딩
- 종만북
- Algorithm
- BASIC
- Algospot
- 백준
- web
- 따라하면서 배우는 C언어
- server
- 인프런
- BOJ
- DP
- C언어
- Python
- greedy
- Math
- 정수론
- BFS
- udemy
- String
Archives
- Today
- Total
몽상실현개발주의
[따배씨] 6.16 배열 과 런타임 에러 본문
따배씨 - 따라하며 배우는 C언어
6강 반복문
6.16 배열 Array 과 런타임 에러 Runtime error
#include <stdio.h>
#define NUM_DAYS 365
int main()
{
char my_chars = "Hello, World!";
int daily_temperature[NUM_DAYS];
double stock_prices_history[NUM_DAYS];
printf("%zd\n", sizeof(stock_prices_history));
// 2920
printf("%zd\n", sizeof(double) * NUM_DAYS);
// 2920
printf("%zd\n", sizeof(stock_prices_history[0]));
// 8
return 0;
}
#include <stdio.h>
int main()
{
int my_numbers[5];
my_numbers[0] = 1; // subscripts, indices, offsets
my_numbers[1] = 3;
my_numbers[2] = 4;
my_numbers[3] = 2;
my_numbers[4] = 1024;
printf("%d\n", my_numbers[0]);
// 1
printf("%d\n", my_numbers[1]);
// 3
printf("%d\n", my_numbers[2]);
// 4
printf("%d\n", my_numbers[3]);
// 2
printf("%d\n", my_numbers[4]);
// 1024
return 0;
}
#include <stdio.h>
int main()
{
int my_numbers[5];
my_numbers[0] = 1; // subscripts, indices, offsets
my_numbers[1] = 3;
my_numbers[2] = 4;
my_numbers[3] = 2;
my_numbers[4] = 1024;
/* Runtime Error */
my_numbers[5] = 123; // out of bound
my_numbers = 10; // Compile error
printf("%d", my_numbers[10]); // out of bound
return 0;
}
- Out of bound 의 경우 Runtime 단계에서 Error 발생
- Compile time 과 Runtime 모두에서 Errorr 가 없는 프로그램을 작성하여야 한다
이 글의 모든 사진과 내용의 출처는 홍정모 교수님께 있음을 알려드립니다.
'Language > C' 카테고리의 다른 글
[따배씨] 7.1 분기문 (0) | 2021.05.21 |
---|---|
[따배씨] 6.17 for 루프를 배열과 함께 사용하기 ~ 6.18 루프 안에서 함수의 반환값 사용하기 (0) | 2021.05.21 |
[따배씨] 6.13 탈출조건 루프 do while ~ 6.15 중첩된 루프들 (0) | 2021.05.20 |
[따배씨] 6.12 제논의 역설 시뮬레이션 예제 (0) | 2021.05.20 |
[따배씨] 6.10 다양한 대입 연산자들 ~ 6.11 콤마 연산자 (0) | 2021.05.20 |
Comments