Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. pointer declaration

pointer declaration

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Oriented
    wrote on last edited by
    #1

    1. what are the differences among: CString* str; , CString *str; and (CString*) str; ?! 2. what are LPVOID,LPCTSTR,LPTSTR,LPARAM... (u may give me a link) thx

    M L L 3 Replies Last reply
    0
    • O Oriented

      1. what are the differences among: CString* str; , CString *str; and (CString*) str; ?! 2. what are LPVOID,LPCTSTR,LPTSTR,LPARAM... (u may give me a link) thx

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      These two mean the same thing:

      CString* str;
      CString *str;

      Since whitespace is not important, they have the identical meaning. The first one is more common among C++ programmers, while the second way is more common among old-school C programers. This:

      (CString*) str;

      is not a declaration at all. It's an expression statement that casts str to CString* and then throws away the result. --Mike-- LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ | You Are Dumb Magnae clunes mihi placent, nec possum de hac re mentiri.

      1 Reply Last reply
      0
      • O Oriented

        1. what are the differences among: CString* str; , CString *str; and (CString*) str; ?! 2. what are LPVOID,LPCTSTR,LPTSTR,LPARAM... (u may give me a link) thx

        L Offline
        L Offline
        LighthouseJ
        wrote on last edited by
        #3

        1. There is no difference between the first and second declarations, but the third, you are casting str, whatever it is, as a CString and therefore is dissimmilar. 2. Those are data types that are all pointers to established types. LPVOID is a pointer to any type of data. LPCTSTR translates to an LPCWSTR (constant null-terminated string of 16-bit Unicode characters) if UNICODE is defined, else it defaults to constant null-terminated 8-bit Windows ANSI characters, in other words, if UNICODE is define, you'll get a wider string. LPARAM is a message parameter. I paraphrased from a Windows Data Types page in this Visual Studio .NET help file, not a website. If anyone wants to correct something or add, be my guest.

        1 Reply Last reply
        0
        • O Oriented

          1. what are the differences among: CString* str; , CString *str; and (CString*) str; ?! 2. what are LPVOID,LPCTSTR,LPTSTR,LPARAM... (u may give me a link) thx

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          i think the two replies above this one has done question 1 enough justice. as for LPVOID, LPCTSTR, LPTSTR, LPARAM and so on... they are Microsoft defined macros of otherwise basic types... think of it this way.... L = LONG = long P = represents the * (pointer) LP = pointer of size long VOID = void C = const T = TCHAR TCHAR = char or wchar_t depending on if the UNICODE macro is defined STR = string PARAM = parameter so LPVOID is just (long) pointer to void/anything LPCTSTR is just a (long) pointer to a const string of type TCHAR for more Microsoft defined types lookup "Windows Data Types" Cheers

          R T 2 Replies Last reply
          0
          • L Lost User

            i think the two replies above this one has done question 1 enough justice. as for LPVOID, LPCTSTR, LPTSTR, LPARAM and so on... they are Microsoft defined macros of otherwise basic types... think of it this way.... L = LONG = long P = represents the * (pointer) LP = pointer of size long VOID = void C = const T = TCHAR TCHAR = char or wchar_t depending on if the UNICODE macro is defined STR = string PARAM = parameter so LPVOID is just (long) pointer to void/anything LPCTSTR is just a (long) pointer to a const string of type TCHAR for more Microsoft defined types lookup "Windows Data Types" Cheers

            R Offline
            R Offline
            Ryan Binns
            wrote on last edited by
            #5

            Actually, LPVOID and PVOID are the same thing. The L doesn't mean anything any more, and is simply a hangover from the 16-bit DOS/Windows days. Back then:

            • PVOID was a NEAR pointer that pointed to an address in the same segment and required 16 bits of storage
            • LPVOID was a FAR pointer that could point to anywhere in the memory address space and required 32 bits of storage

            Under Win32, there is no concept of NEAR and FAR pointers since the address space is a flat 32-bit address space and segments are not required.

            Ryan

            "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

            1 Reply Last reply
            0
            • L Lost User

              i think the two replies above this one has done question 1 enough justice. as for LPVOID, LPCTSTR, LPTSTR, LPARAM and so on... they are Microsoft defined macros of otherwise basic types... think of it this way.... L = LONG = long P = represents the * (pointer) LP = pointer of size long VOID = void C = const T = TCHAR TCHAR = char or wchar_t depending on if the UNICODE macro is defined STR = string PARAM = parameter so LPVOID is just (long) pointer to void/anything LPCTSTR is just a (long) pointer to a const string of type TCHAR for more Microsoft defined types lookup "Windows Data Types" Cheers

              T Offline
              T Offline
              toxcct
              wrote on last edited by
              #6

              Sawjai wrote: i think the two replies above this one has done question 1 enough justice. as for LPVOID, LPCTSTR, LPTSTR, LPARAM and so on and i'd conclude by saying :

              typedef void* LPVOID;
              typedef const TCHAR* LPCTSTR;
              typedef TCHAR* LPTSTR;
              typedef DWORD LPARAM;
              //...
              #ifdef _UNICODE
              #define TCHAR wchar_t;
              #else
              #define TCHAR char;
              #endif


              TOXCCT >>> GEII power
              [toxcct][VisualCalc]

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups