Easy 40pts. outtextxy

Ok, this is easy and i am sure the first person to answer this will get it. I am using Turbo C++, Dos, and i just plain forgot how to outtextxy a varible. Example:

//In a game i have:
int hits=2;
// I want to outext xy this to the screen
int hittemp[10]; //i remember i had to do this
printf(/*i forget what to put in here*/);
outextxy(100,100,/*i forget what to put here to*/);
please help! Tell me how to fix this! Thanks!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

outtextxy.... that's a BGI function, isn't it? If you're not in graphics mode, that would be a problem. The third parameter for outtextxy is, of course, the character string you want to print. To display hits you need to create a character array the length of your hits variable (plus 1 for the \0 character), and store the variable into that array.
if hits is less than 10:
   char hittemp[2];
   hittemp[0] = hits+'0';
if hits is greater than/equal to 10:
   char hittemp[3];
   hittemp[0] = (hits/10)+'0';
   hittemp[1] = (hits%10)+'0';

then just outtextxy(100,100,hittemp);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PunkmanAuthor Commented:
Ya, i am in graphics mode. I forgot! The reason i hade an array (i don't think you need one) is beause the last time i used it it was to output a varible that was a letter. Lets just say hits is a changing varible, it could be 1 or 2 or 6. I remember you had to convert it, but i am pretty sure you hade to use
//and then
outtextxy(100,100,hittemp or something)
right? I think i understand what you are saying.
PunkmanAuthor Commented:
no, wait you did have to use an array...i think...
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Yeah I see what you're saying. You're using printf() to store the int into the char array instead of doing it manually. That should be fine, but you still have to ensure you allocate enough characters to store the variable when you declare hittemp.
PunkmanAuthor Commented:
So it would be like:

int hit=2;
int(or char?) temphit[10];
outtextxy(100,100,temphit(or hit?);

would that be right?
PunkmanAuthor Commented:
I get it! Ok i see exactly what you mean! It would be like this:

char hittemp[10];
int hit=2;
sprintf(hittemp,"%d",hit); //note not printf like i thought

There just like that. Thanks, i give you the points.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.