xFear of Napalm
07-10-2010, 06:32 AM
I'm currently programming a simple console program for Rubik's
Cube scrambles in Dev-C++ 4.9.9.2, and I've declared "move" as
a char as such:
char move;
When i try to assign a value later in the program in an if statement,
I get a compiler error saying that I cannot convert a constant char
into a char! Why is this happening?
I'm extraordinarily new to C++ and it's syntax, so I'm sorry if I'm over-
looking something big here...
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <cmath>
using namespace std;
int main()
{
int trnface;
char move;
bool dblturn;
bool inverse;
unsigned short int movecount;
string scramble = "";
int a;
cout << "I will create a Rubik's Cube scramble for you.\nHow many moves do you desire?\n" ;
cin >> movecount;
srand((unsigned)time(0));
for(a = 1; a <= movecount; ++a)
{
trnface = (rand() % 6 + 1);
cout << trnface;
if (trnface = 1)
{move = "F";}
if (trnface = 2)
{move = "B";}
if (trnface = 3)
{move = "L";}
if (trnface = 4)
{move = "R";}
if (trnface = 5)
{move = "U";}
if (trnface = 6)
{move = "D";}
cout << move;
}
system("PAUSE");
}
Here's all the code that I have written so far, and I've created similar
programs in VB...
Cube scrambles in Dev-C++ 4.9.9.2, and I've declared "move" as
a char as such:
char move;
When i try to assign a value later in the program in an if statement,
I get a compiler error saying that I cannot convert a constant char
into a char! Why is this happening?
I'm extraordinarily new to C++ and it's syntax, so I'm sorry if I'm over-
looking something big here...
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <cmath>
using namespace std;
int main()
{
int trnface;
char move;
bool dblturn;
bool inverse;
unsigned short int movecount;
string scramble = "";
int a;
cout << "I will create a Rubik's Cube scramble for you.\nHow many moves do you desire?\n" ;
cin >> movecount;
srand((unsigned)time(0));
for(a = 1; a <= movecount; ++a)
{
trnface = (rand() % 6 + 1);
cout << trnface;
if (trnface = 1)
{move = "F";}
if (trnface = 2)
{move = "B";}
if (trnface = 3)
{move = "L";}
if (trnface = 4)
{move = "R";}
if (trnface = 5)
{move = "U";}
if (trnface = 6)
{move = "D";}
cout << move;
}
system("PAUSE");
}
Here's all the code that I have written so far, and I've created similar
programs in VB...