We are working on a project for C++, and it is to take the users input of either (a) number of a gauge on a resistor or (b) the name as in "green" or "yellow" and it converts both ways. We can't set the value of a string to an array, we get a "cannot convert character[6] to int, but for all of them. Here is a piece of the code:
void numberstocolors(string &value)
{
int i(0);
string a;
char ourstring[4]=value;
while (ourstring != '\0')
{
int a;
if (value=="0")
a="black";
if (value=="1")
a="brown";
if (value=="2")
a="red";
if (value=="3")
a="orange";
if (value=="4")
a="yellow";
if (value=="5")
a="green";
if (value=="6")
a="blue";
if (value=="7")
a="violet";
if (value=="8")
a="grey";
if (value=="9")
a="white";
i++
}
}
void numberstocolors(string &value)
{
int i(0);
string a;
char ourstring[4]=value;
while (ourstring != '\0')
{
int a;
if (value=="0")
a="black";
if (value=="1")
a="brown";
if (value=="2")
a="red";
if (value=="3")
a="orange";
if (value=="4")
a="yellow";
if (value=="5")
a="green";
if (value=="6")
a="blue";
if (value=="7")
a="violet";
if (value=="8")
a="grey";
if (value=="9")
a="white";
i++
}
}