LPSTR or something like that
-
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....
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
-
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....
-
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....
#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; }
我爸是李刚
-
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
-
-
#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; }
我爸是李刚