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
How to whitelist website on AdBlocker?

How to whitelist website on AdBlocker?

  1. 1 Click on the AdBlock Plus icon on the top right corner of your browser
  2. 2 Click on "Enabled on this site" from the AdBlock Plus option
  3. 3 Refresh the page and start browsing the site