std::string to LPCSTR

Apr 3, 2013 at 3:13pm
Hi all! I write console FTP client and use WinInet.h. One of the InternetConnect function's parameter is LPCSTR lpszServerName. But i transfer string argument.
For examle:
HINTERNET ConnectParam=InternetOpen(hInternet,"ftp.vladsserver.ru",port,"login","pas",INTERNET_SERVICE_FTP,INTERNET_FLAG_PASSIVE,0);
But i have an error. How I can convert std:string to LPCSTR? I hope you can help me.
PS: Sorry for my English - i'm from Kazakhstan and English is not my native language:)
Last edited on Apr 3, 2013 at 3:13pm
Apr 3, 2013 at 3:21pm
Apr 3, 2013 at 3:23pm
mutexe, thank you. But can you give me little example?
Apr 3, 2013 at 3:27pm
There's some in that link.
Just google your thread title for more examples.
Apr 3, 2013 at 3:33pm
1
2
	std::string newString("wibble");
	LPCTSTR oldString = newString.c_str();


then pass in to your method.
Apr 3, 2013 at 3:34pm
I found this!
MyString.c_str();
Apr 3, 2013 at 3:34pm
exactly.
Apr 3, 2013 at 6:31pm
- Wait, are you trying to convert a string to a constant string pointer? Interesting.
Last edited on Apr 3, 2013 at 6:32pm
Topic archived. No new replies allowed.