E0144-a value of type "const char *" cannot be used to initialize an entity of type "char *"

CODEDRAGON Development/C, C++

반응형

 

오류 메시지

문자열은 상수인데 char배열로 저장하려하기 때문에 오류가 발생합니다.

Severity        Code        Description        Project        File        Line        

Suppression State

Error (active)        E0144        a value of type "const char *" cannot be used to initialize an entity of type "char *"        Test        c:\CodeLab\workspace_cplusplus\Test\Test\Source.cpp        15        


 

 

 

 

해결방법

아래의 코드를 const 상수화하여 사용합니다.

문자열은 상수므로 변경할 없도록 상수화하여 사용하면 됩니다.

수정

char *str = "12345678901234567890";

 

수정

const char *str = "12345678901234567890";

 

 



반응형