Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

char * and CString only become True or False?

$
0
0

Hello!

I am pretty new to C++. Right now I am trying to write a program (CLR-Console) that reads out codes from transponder-cards. There is a demo-program with source code. While I managed to include all the .dll and do the linkage and make my program recognize wether a USB-Reader is connected I am having problems with the following:

char * USBNamesBuffer = new char[255]; //is true?


...is "True" when I let it show up in the console.

A part of the code looks like this:

if(numDevs == 1)
  {
    CString strPortName;
	  char * USBNamesBuffer = new char[255]; //"True"
      strPortName = USBNamesBuffer; //"True"
      m_PortHandle = TSHRW_OpenPort(strPortName,19200,1000); //strPortName is "True" thus that doesn't work properly...
      if(m_PortHandle < 0)
      {
        m_PortHandle = NULL;
      }
      else
      {
        TSHRW_SetReaderMode(m_PortHandle,1);//returns -1 which means there was an error...
      }
    }
    delete []USBNamesBuffer;
  }

The demoprogram manages to receive the correct strPortName, which should be 1460-0857 HID in my case. When I insert it instead of strPortName it works.

Any idea why my CString and char would only become "True"?

Best regards!


Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>