강의

멘토링

커뮤니티

Inflearn Community Q&A

listenandcreate0709's profile image
listenandcreate0709

asked

Hong Jung-mo's Follow Along and Learn C Programming

12.15 Using dynamically allocated memory as an array

(강의 15분 30초) static const int cr = col*row ;

Resolved

Written on

·

402

0

강의 15분 30초에

static const int cr = col*row;

이 부분을 해보니

col*row에 빨간 밑줄이 나오며

expression must have a constant value

라고 합니다.

c

Answer 2

1

Hyo Jun Bae님의 프로필 이미지
Hyo Jun Bae
Questioner

넵 답변 감사드립니다! 

1

https://www.geeksforgeeks.org/static-variables-in-c/
에 따르면 static 이 붙으면 C에서는 initialization을 해줄때 variable을 사용할 수 없는 것 같네요.
표현을 빌려오자면.. 'static variables can only be initialized using constant literals.'
C++에서는 허용해주는데 C++에서 사용하시던 코드를 그대로 가져온 게 아닐까 생각되는군요.

listenandcreate0709's profile image
listenandcreate0709

asked

Ask a question