简体   繁体   English

C ++ [错误]分配只读位置'*(a +((sizetype)((((long long unsigned int)min)* 4ull)))''

[英]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.

相关问题 只读位置&#39;__result.std :: _ Rb_tree_const_iterator &lt;_Tp&gt; :: operator *的错误分配 <long long int> ()” - Error assignment of read-only location '__result.std::_Rb_tree_const_iterator<_Tp>::operator*<long long int>()' C ++错误:分配只读位置 - C++ error:Assignment of read-only location 错误:&#39;18446744069414584320ull&#39;从&#39;long long unsigned int&#39;到&#39;int&#39;的缩小转换{} [-Wnarrowing] - error: narrowing conversion of ‘18446744069414584320ull’ from ‘long long unsigned int’ to ‘int’ inside { } [-Wnarrowing] Unordered_map(C ++)中的“错误:分配只读位置” - “error: assignment of read-only location” in unordered_map (C++) “ unsigned long int”和“ unsigned long long int”分配问题 - 'unsigned long int', and 'unsigned long long int' assignment issue 在C ++中从无符号long long转换为unsigned int - Conversion from unsigned long long to unsigned int in C++ 错误:只读位置“* __result”的分配 - error: assignment of read-only location ‘* __result’ 将unsigned int转换为unsigned long int C ++ - Typecast an unsigned int to unsigned long int C++ 在 C++ 中将 unsigned (long) int 解释为有符号 - Interpreting an unsigned (long) int as signed in C++ C ++中“ unsigned long int”的最大值 - The maximum value of “unsigned long int” in c++
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM