Integer conversion help

A

Altman

I am trying to write a program to write to the com port. I have some sample
code and it says to use the function
hComm = CreateFile("COM2",
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
0,
0);
where if it is com 1 then the first argument is "COM1". I want to make this
programatically though where I set the com port as a short and convert it to
"COM" + STR(sComPort). I am still quite new to C++ and I need to know how
to do this.
--
Altman


Forward this to everyone on your email list and Bill Gates will Magically
Pop Out of your computer and hand you a check for $500 per person you sent
it to, and he will also mail a check to a starving Ethiopian in China with
Brain Cancer.
 
B

Ben Schwehn

the most straightforward is probably something like:

char name[5];
sprintf_s(name, 5, "COM%d", number);

CreateFile(name ...


done!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top