错误:无法转换'的std :: basic_string的<&烧焦GT;'在分配“字符” [英] error: cannot convert 'std::basic_string<char>' to 'char' in assignment

查看:170
本文介绍了错误:无法转换'的std :: basic_string的<&烧焦GT;'在分配“字符”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我编译这个code,我总是得到这个错误。在这里,DNA被设置为CHAR。我想在此位集的位值,以被转换为炭和焦炭到中间体如果这是不正确的做法,请指导。

 为(的std ::为size_t我= 0; I< myString.size(); ++ I)
{
    和std :: bitset< 8' Y(MyString的[I]);    DNA = y.to_string<&烧焦GT;();
    二进制= DNA;
    COUT<<二进制<< ;
    而(二进制> = 10){
        的for(int i = 0; I< = 100; ++ I){//循环数组长度
            一个由[i] =二进制%10;
            二进制=二进制/ 10;
        }
    }
}


解决方案

y.to_string(); 收益的std ::字符串。它不能被转换为字符

使用这样的:

 的std ::串DNA = y.to_string();
无符号长二进制= y.to_ulong();

人们,请不要投了我的帖子。我需要它的顽强的徽章。

When I am compiling this code, I always get this error. Here dna is set to char. I want the bit value in the bitset to be converted to a char and the char to a int. If this is not the right way, please guide.

for (std::size_t i = 0; i < myString.size(); ++i)  
{
    std::bitset<8> y(myString[i]);

    dna = y.to_string<char>();
    binary = dna;
    cout << binary << " ";
    while ( binary >= 10) {
        for(int i = 0; i <= 100; ++i) { // loops length of array
            a[i] = binary % 10;
            binary = binary / 10;
        }
    }
}

解决方案

y.to_string(); returns std::string. It can't be converted to char.

Use this:

std::string dna = y.to_string();
unsigned long binary = y.to_ulong();

People, please don't up vote my post. I need it for the "Tenacious" badge.

这篇关于错误:无法转换'的std :: basic_string的&LT;&烧焦GT;'在分配“字符”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆