code problem: error

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

how do i overcome this: here is my code :

#include<iostream>
#include"110ct.h"
#include<string>

using namespace std;

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";



cin.get();

return 0;
}
Last edited on
You have not declared movement.
i Did declare movement and it still doesnt work
closed account (o1vk4iN6)
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.
i need the character that the user inputs to move down the stairs using , keypress such as W,A,S,D
closed account (o1vk4iN6)
"the stairs", What stairs? Give an example of what you are doing.

You want this in real time like a game of some sort? One sentence repeating what you already said is not elaborating. Help us help you.
Last edited on
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.

sorry for not explaining it well
Topic archived. No new replies allowed.