[英]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.
我的老师真的很糟糕,他没有教我们如何更改const类型的上下文或地址。 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. 有我的代码,放置了一个数组,然后对其进行排序,但是当我尝试交换a [min]和a [i]时,发现我错了。 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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.