我有一个数组:
CHAR m_manuf[256];
我正在尝试将值复制到此数组:
m_manuf = "abacus"; //This shows error
我也尝试过这种变化:
char abc[256] ="abacus";
m_manuf = abc; //Shows error as left value must be l-value
答案 0 :(得分:2)
你不能'像这样复制一个数组,而不是你能做到的,
operator_plus.hpp:164:1: note: template<class T1, class T2> typename arma::enable_if2<((arma::is_arma_sparse_type<T1>::value && arma::is_arma_sparse_type<T2>::value) && arma::is_same_type<typename T1::elem_type, typename T2::elem_type>::value), arma::SpGlue<T1, T2, arma::spglue_plus> >::result arma::operator+(const T1&, const T2&)
operator_plus.hpp:164:1: note: template argument deduction/substitution failed:
operator_plus.hpp:164:1: error: no type named ‘result’ in ‘struct arma::enable_if2<false, arma::SpGlue<arma::SpMat<double>, arma::SpMat<std::complex<double> >, arma::spglue_plus> >’
或者
CHAR m_manuf[256];
strcpy(m_manuf,"abacus" );
或者
char * m_manuf = "abacus";
注意:处理char数组的更好方法是使用std :: string,
答案 1 :(得分:0)
一个常量的char数组对你来说已经足够了,所以你可以选择,
char *new = &tmp[0];
或者您需要修改新的char数组并且常量不正常,那么只需使用此
<?
// Your test array 1
$arr1[] = array('Title'=>'Ground','Price'=>'3.15');
$arr1[] = array('Title'=>'2 Day','Price'=>'12.11');
$arr1[] = array('Title'=>'1 Day','Price'=>'29.26');
foreach ($arr1 as $key => $value) {
$newArr[$value['Title']] = $value['Price'];
}
echo "<pre>";
print_r($newArr); // result of array1, you can follow this for other arrays as well
?>