Thread: Data types in Embedded C++

  1. #1
    Registered User
    Join Date
    Oct 2011

    Data types in Embedded C++

    I have this code:

    Edit_SetText(hctl_data, (LPTSTR)SCNBUF_GETDATA(lpScanBuffer));

    Edit_SetText have parameters type HWND y LPTSTR, (LPTSTR) convert to LPTSTR the content of SCNBUF_GETDATA(lpScanBuffer)

    I need convert the content of SCNBUF_GETDATA(lpScanBuffer) to CHAR type, in order to use in the command fputs(), I mut use (CHAR) before ?? (I try this and gives me a en error)

    any suggestion??

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Casts don't convert anything at all when you're dealing with pointers.

    char *p = "1234";

    int *q = (int*)p;
    doesn't make *q magically return the numeric value 1234.

    You need to find some appropriate conversion function, which takes a TSTR and returns a char pointer.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Oct 2011
    OK, thanks for your answer

    in "Edit_SetText(hctl_data, (LPTSTR)SCNBUF_GETDATA(lpScanBuffer));"

    what (LPTSTR) does over SCNBUF_GETDATA(lpScanBuffer) ?
    can you explain to me, or advice me a doc to learn about, I'm a VFP programmer, I need to modify this code in c++ in order to make functional a data collector.

  4. #4
    Join Date
    Oct 2007
    Inside my computer
    LPTSTR is a typedef for some pointer to some string. But a pointer is a variable that points to some location and the type tells the compiler how to interpret the data. Casting to another pointer type simply changes how the compiler interprets the data. It does not actually change any of the data stored (ie, convert it to another type)!
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what are the data types?
    By Milhas in forum C Programming
    Replies: 3
    Last Post: 03-26-2008, 08:31 AM
  2. Data Types
    By drrcknlsn in forum C++ Programming
    Replies: 7
    Last Post: 01-17-2008, 03:52 AM
  3. data types types...
    By gftmc in forum C++ Programming
    Replies: 3
    Last Post: 09-11-2006, 11:30 AM
  4. data types
    By Micko in forum Windows Programming
    Replies: 2
    Last Post: 05-18-2004, 06:23 AM
  5. Data types
    By KrAzY CrAb in forum C Programming
    Replies: 4
    Last Post: 02-04-2003, 06:43 AM

Tags for this Thread