Questions tagged [lpcstr]

Use this tag for questions related to the LPCSTR data type.

LPCSTR is a common data type used in Windows programming for representing strings. Its name is an acronym that stands for Long Pointer to Const String. From the corresponding MSDN page:

An LPCSTR is a 32-bit pointer to a constant null-terminated string of 8-bit Windows (ANSI) characters.

This type is declared as follows:

typedef const char* LPCSTR;
56 questions
117
votes
3 answers

What does LPCWSTR stand for and how should it be handled?

First of all, what is it exactly? I guess it is a pointer (LPC means long pointer constant), but what does "W" mean? Is it a specific pointer to a string or a pointer to a specific string? For example I want to close a Window named "TestWindow".…
lhj7362
  • 2,173
  • 4
  • 19
  • 17
15
votes
9 answers

How to find the length of an LPCSTR

I'm trying to convert an LPCSTR to an integer using atoi(), and to verify that the conversion occurred successfully I want to count the number of digits in the integer it produced and the original LPCSTR (it should contain nothing but integers) I'm…
Zain Rizvi
  • 23,586
  • 22
  • 91
  • 133
11
votes
2 answers

C++ CLI System.String^ to MFC LPCTSTR

How would I convert a System (.net) C++\CLI String^ into a MFC C++ LPCTSTR string. It is very easy to get a LPCTSTR into String^, but so far found nothing on doing it the other way around.
Landin Martens
  • 3,283
  • 12
  • 43
  • 61
7
votes
2 answers

What is Linux equivalent of LPTSTR & LPCSTR?

I am converting windows library to linux. I need to find LPTSTR and LPCSTR in linux. I get to know that i can use wchar_t can be used but I am not really sure about using it. one of the method that uses LPTSTR is as follows: void ErrorExit(LPTSTR…
jparthj
  • 1,606
  • 3
  • 20
  • 44
6
votes
3 answers

How do I convert an LPTSTR to an LPCSTR?

So the output of the function GetUserName() gives the username as a LPTSTR. I need to convert this to a LPCSTR, as I want the username to be the name of the an ftpdirectory. TCHAR id [UNLEN+1]; DWORD size = UNLEN+1; GetUserName(id, &size); // this…
Rob
  • 175
  • 3
  • 3
  • 12
4
votes
3 answers

C++ MFC how to compare LPCTSTR in a if statement?

I have the following code: LPCTSTR strPermission = Method(); if (strPermission == L"0") { return true; } else { return false; } While debugging I can see that strPermission does equal "0", yet when I compare it like in the if statement it…
Landin Martens
  • 3,283
  • 12
  • 43
  • 61
4
votes
2 answers

How to compare LPCSTR

I have already tried strcmp and lstrcmp. I even tried to get do it with strlen but didn't work either, here is what I have void check(LPCSTR lpText) { if( strmp(lpText, "test") == 0) { MessageBoxW(0, L"equal", 0, 0); } else …
method
  • 1,369
  • 3
  • 16
  • 29
3
votes
4 answers

How to convert QString to LPCSTR (Unicode)

how can I convert QString to LPCSTR ? How do I do it when #ifdef UNICODE is defined and when it isn't ? Thanks very much :)
user666491
3
votes
4 answers

How to Concatenate Two LPCSTRs

I have two LPCSTRs I need to concatenate like so: if (!rename(directory + originalFileName, directory + fileName)){ std::cout<
3
votes
1 answer

Comparing two LPCSTR with ==

I found out an implementation that compares two LPCSTR doing the following: void check(LPCSTR lpText) { if(lpText == input) { // do stuff } } The problem is that it works. I replaced it with... if(lstrcmpi(lpText, input) ==…
Claudiordgz
  • 3,023
  • 1
  • 21
  • 48
3
votes
2 answers

How does one convert LPTSTR to LPCTSTR?

I need to convert: http://msdn.microsoft.com/en-us/library/windows/desktop/ms646839(v=vs.85).aspx lpstrFileTitle Type: LPTSTR The file name and extension (without path information) of the selected file. This member can be NULL. Even though in…
User
  • 659
  • 2
  • 12
  • 29
3
votes
2 answers

FindFirstFile LPCSTR

Hello i got a problem with my code here. LPCSTR mergeString(LPCSTR firstString, std::string secondString) { string convertedString = ConvertString(firstString); LPCSTR mergedString; int i = convertedString.size(); …
user1812707
  • 67
  • 1
  • 7
3
votes
2 answers

Appending BSTR in a LPCSTR

I have a class function which is receving a BSTR. In my class I have a member variable which is LPCSTR. Now I need to append BSTR ins LPCSTR. How I can do that. Here is my function. void MyClass::MyFunction(BSTR text) { LPCSTR name = "Name: "; …
fhnaseer
  • 7,159
  • 16
  • 60
  • 112
2
votes
3 answers

Why does MFC C++ CString(const char*) completely changing const char* value?

I hope the title was good enough to help explain what I am having problems with. I think once I solve this problem my project will be pretty much finished. Just a note, both projects are compiled under Unicode. I am working with a CLI/C++ DLL that…
Landin Martens
  • 3,283
  • 12
  • 43
  • 61
2
votes
5 answers

How to use Templates when working with std::strings and c-style strings?

I was just messing around with templates, when I tried to do this: template void print_error(T msg) { #ifdef PLATFORM_WIN32 ::MessageBox(0, reinterpret_cast< LPCSTR >(msg), "Error", MB_ICONERROR|MB_OK); #else cout << msg <<…
ApprenticeHacker
  • 21,351
  • 27
  • 103
  • 153
1
2 3 4