int main(int argc, char** argv) { const char* foo = “wow”; // line 1 foo = “top”; // line 2 foo[0] = 1; // line 3 return 0; }  For the code below which lines should be reported as errors by a compiler?

int main(int argc, char** argv)

{

const char* foo = “wow”; // line 1

foo = “top”; // line 2

foo[0] = 1; // line 3

return 0;

}

 For the code below which lines should be reported as errors by a compiler?

A. 1

B. 2

C. 3

D. None of the lines

Hướng dẫn

Chọn C là đáp án đúng

Xem lời giải

Xem lời giải

Biến foo là biến const, trình biên dịch không cho phép thay đổi giá trị của biến foo.

 

Thư viện tài liệu12 Tháng bảy, 2023 @ 3:09 chiều

Đánh giá chủ đề này