Integer conversion help

  • Thread starter Thread starter Altman
  • Start date Start date
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.
 
the most straightforward is probably something like:

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

CreateFile(name ...


done!
 
Back
Top