79343091

Date: 2025-01-09 15:09:12
Score: 0.5
Natty:
Report link

As an addendum to @adelphus' answer, you can also use raw string literals to make things a little bit more readable maybe.

myPort = CreateFile(R"(\\.\COM14)",
          GENERIC_READ | GENERIC_WRITE,
          0,    /* exclusive access  */
          NULL, /* no security attrs */
          OPEN_EXISTING,
          0,
          NULL );

Although seeing as CreateFile() is a macro that may resolve to CreateFileW() you may also need to turn this into a wide string

myPort = CreateFile(LR"(\\.\COM14)",
          GENERIC_READ | GENERIC_WRITE,
          0,    /* exclusive access  */
          NULL, /* no security attrs */
          OPEN_EXISTING,
          0,
          NULL );

Applies here because the question is tagged C++ and requires as least C++11. Does not apply to C.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @adelphus'
  • Low reputation (0.5):
Posted by: iwarv