[Rustling] exercises/01_variables/variables6.rs 풀기

2024. 10. 11. 16:51·Programming Language/RUST

문제

상수 변수에 데이터 타입이 명시되지 않아 발생한 에러이다.

 

풀이

소스 코드를 살펴보자

// TODO: Change the line below to fix the compiler error.
const NUMBER = 3;

fn main() {
    println!("Number: {NUMBER}");
}

`TODO`에서도 상수 변수 선언 부분을 수정하라고 지시하고 있다.

 

데이터 타입을 명시해 주자.

// TODO: Change the line below to fix the compiler error.
const NUMBER:i32 = 3;

fn main() {
    println!("Number: {NUMBER}");
}

 

저장하면,

해결

 

Rust에서 상수를 선언할 때에는 데이터 타입을 명시해 주자!

저작자표시 비영리 (새창열림)

'Programming Language > RUST' 카테고리의 다른 글

Rust 함수 동작 원리  (0) 2024.10.22
[Rustling] exercises/01_variables/variables5.rs 풀기  (0) 2024.10.11
[Restling] exercises/01_variables/variables4.rs 풀기  (0) 2024.10.11
[Rustling] exercises/01_variables/variables3.rs 풀기  (0) 2024.10.11
[Rustling] exercises/01_variables/variables2.rs 풀기  (0) 2024.10.11
'Programming Language/RUST' 카테고리의 다른 글
  • Rust 함수 동작 원리
  • [Rustling] exercises/01_variables/variables5.rs 풀기
  • [Restling] exercises/01_variables/variables4.rs 풀기
  • [Rustling] exercises/01_variables/variables3.rs 풀기
602zzang
602zzang
  • 602zzang
    yks_STUDY
    602zzang
  • 전체
    오늘
    어제
    • 분류 전체보기 (77)
      • Programming Language (36)
        • C (15)
        • PYTHON (9)
        • RUST (12)
      • Reverse Engineering (3)
      • OS (17)
        • LINUX (17)
      • 보안 이슈 (6)
      • Digital Forensics (1)
      • CTF (8)
      • 기타 (6)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    umassctf2025
    백준
    Rocky Linux
    파이썬
    bandit
    빡공팟
    python
    picoCTF
    rust
    cyberdefenders
    TeamH4C
    P4C
    c
    보안동향
    소켓 통신
    rustling
    공급망
    보안이슈
    코드업
    드림핵
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.0
602zzang
[Rustling] exercises/01_variables/variables6.rs 풀기
상단으로

티스토리툴바