im having problem with my code i need my character to move down the stairs , however i get an error message saying char movement is being used without being initialized
int main()
{
CursorController crs;
ColourController cl;
int Number;// the number of stairs
int Amount = 1; // this is the amount of x it will add to the line
string A;// this is the variable for the character
char movement;// this is the variable to move the character
double xval ,yval;
xval= 20;// the set x postion coordinates
yval = 20;//the set x postion coordinates
cout << "Enter in how many 'stairs' you want" << endl;
cin >> Number;
cout << " now enter a special character to move up and down the starirs \n";
cin >> A;
for(int i = 0; i < Number; i++)
{
for(int j = 0; j < Amount; j++)
{
cout << "*";//the charater for the stair
}
cout << endl;
Amount +=1; //Adds 1 'X' after every new line
}
while( movement =='i')
{
yval=yval-0.5;
crs.setPosition(xval,yval);
cout << A <<"\n";
qin>>movement;
crs.clearAll();
cout<< " to move the special character press the following keys \n";
cout<< " press i for up \n k for down \n j for left and l for right \n";// intructions for the keys
}
while( movement == 'k')
{
yval=yval+0.5;
crs.setPosition(xval,yval);
cout << A <<"\n";
qin>>movement;
crs.clearAll();
cout<< " to move the special character press the following keys \n";
cout<< " press i for up \n k for down \n j for left and l for right \n";// intructions for the keys
}
while( movement == 'j')
{
xval=xval-0.5;
crs.setPosition(xval,yval);
cout << A <<"\n";
qin>>movement;
crs.clearAll();
cout<< " to move the special character press the following keys \n";
cout<< " press i for up \n k for down \n j for left and l for right \n";// intructions for the keys
}
while( movement == 'l')
{
xval=xval+0.5;
crs.setPosition(xval,yval);
cout << A <<"\n";
qin>>movement;
crs.clearAll();
cout<< " to move the special character press the following keys \n";
cout<< " press i for up \n k for down \n j for left and l for right \n";// intructions for the keys
}
while(movement!='x')
qin>> movement;
cout<< " you have terminated the program \n";
however i get an error message saying char movement is being used without being initialized
This is not an error, this is a warning. Best learn the difference between the two.
Care to elaborate on what you want this to do, as far as I can tell it doesn't seem like an overly complex program unless you are expecting it to do more than it currently is doing.
my program already creates a type of stair like this : *
* *
***
****
and the user gets to input a character they would like to move down the stairs howver i keep getting the error mention before.