简体   繁体   中英

C++ [Error] assignment of read-only location '*(a + ((sizetype)(((long long unsigned int)min) * 4ull)))'

I have tried to write some print code, but there are always two errors. My teacher was really terrible, he didn't teach us about how to change const type context or address. I really need help, thank you so much.

There is my code, put an array, and sort it, but when I tried to exchange the a[min] and a[i], it noticed me wrong. How to fix it?

在此处输入图片说明

[Error] assignment of read-only location

The error means that you are trying to write to a location that is read-only, or in your case, trying to change a constant.

Change it from

void print_array(const int a[], const int asize)

to

void print_array(int a[], const int asize)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM