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. LPSTR or something like that

LPSTR or something like that

Scheduled Pinned Locked Moved C / C++ / MFC
question
8 Posts 4 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.
  • K Offline
    K Offline
    Krauze
    wrote on last edited by
    #1

    void getPath(LPSTR lpszPath)
    {
    CFile file;
    char pbuf[512];
    ...
    file.Read(pbuf, size);
    // here I wanna copy the first n chars of pbuf into lpszPath
    }

    So what can I do to manage it? Maybe what has confused me is the different string data types....

    A C Y 3 Replies Last reply
    0
    • K Krauze

      void getPath(LPSTR lpszPath)
      {
      CFile file;
      char pbuf[512];
      ...
      file.Read(pbuf, size);
      // here I wanna copy the first n chars of pbuf into lpszPath
      }

      So what can I do to manage it? Maybe what has confused me is the different string data types....

      A Offline
      A Offline
      Ahmed Charfeddine
      wrote on last edited by
      #2

      It is the same as if you were dealing with char* ! Have the habit of discovering what the definition of an unknwon type to you is. In this case you'll find it's just made from a typedef !

      typedef CHAR *LPSTR;

      Push Framework - now released ! http://www.pushframework.com

      K 1 Reply Last reply
      0
      • K Krauze

        void getPath(LPSTR lpszPath)
        {
        CFile file;
        char pbuf[512];
        ...
        file.Read(pbuf, size);
        // here I wanna copy the first n chars of pbuf into lpszPath
        }

        So what can I do to manage it? Maybe what has confused me is the different string data types....

        C Offline
        C Offline
        Chris Losinger
        wrote on last edited by
        #3

        LPSTR is a char*

        typedef char* PSTR, *LPSTR;

        image processing toolkits | batch image processing

        K 1 Reply Last reply
        0
        • K Krauze

          void getPath(LPSTR lpszPath)
          {
          CFile file;
          char pbuf[512];
          ...
          file.Read(pbuf, size);
          // here I wanna copy the first n chars of pbuf into lpszPath
          }

          So what can I do to manage it? Maybe what has confused me is the different string data types....

          Y Offline
          Y Offline
          yu jian
          wrote on last edited by
          #4
          #include "stdafx.h"
          #include <iostream>
          #include "afx.h"
          
          using namespace::std;
          
          void getPath(LPSTR lpszPath, int max)
          {
          	char pbuf[512];
          
          	LPCTSTR lpszFileName = _T("1.txt");
          	CFile mFile(lpszFileName, CFile::modeRead | CFile::shareCompat);
          	if(mFile.GetLength() < 2)
          		return;
          
          	mFile.Read(pbuf, 500);
          	mFile.Close();
          	memcpy(lpszPath, pbuf, 500);
          }
          
          int _tmain(int argc, _TCHAR* argv[])
          {
          	LPSTR lpstr = new char[2000];
          	memset(lpstr, 0, 2000);
          	getPath(lpstr, 2000);
          	return 0;
          }
          

          我爸是李刚

          K 1 Reply Last reply
          0
          • A Ahmed Charfeddine

            It is the same as if you were dealing with char* ! Have the habit of discovering what the definition of an unknwon type to you is. In this case you'll find it's just made from a typedef !

            typedef CHAR *LPSTR;

            Push Framework - now released ! http://www.pushframework.com

            K Offline
            K Offline
            Krauze
            wrote on last edited by
            #5

            thx a lot

            1 Reply Last reply
            0
            • C Chris Losinger

              LPSTR is a char*

              typedef char* PSTR, *LPSTR;

              image processing toolkits | batch image processing

              K Offline
              K Offline
              Krauze
              wrote on last edited by
              #6

              many thx

              1 Reply Last reply
              0
              • Y yu jian
                #include "stdafx.h"
                #include <iostream>
                #include "afx.h"
                
                using namespace::std;
                
                void getPath(LPSTR lpszPath, int max)
                {
                	char pbuf[512];
                
                	LPCTSTR lpszFileName = _T("1.txt");
                	CFile mFile(lpszFileName, CFile::modeRead | CFile::shareCompat);
                	if(mFile.GetLength() < 2)
                		return;
                
                	mFile.Read(pbuf, 500);
                	mFile.Close();
                	memcpy(lpszPath, pbuf, 500);
                }
                
                int _tmain(int argc, _TCHAR* argv[])
                {
                	LPSTR lpstr = new char[2000];
                	memset(lpstr, 0, 2000);
                	getPath(lpstr, 2000);
                	return 0;
                }
                

                我爸是李刚

                K Offline
                K Offline
                Krauze
                wrote on last edited by
                #7

                thx for your detailed example

                Y 1 Reply Last reply
                0
                • K Krauze

                  thx for your detailed example

                  Y Offline
                  Y Offline
                  yu jian
                  wrote on last edited by
                  #8

                  you are welcome.

                  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