473,326 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

string to const TCHAR problems

ree
I need to use a function from a wininet library, it requires the use of
const TCHAR.
The problem is the value needs to be calculated, so at the end I have this
string but I am having troubles converting it into a const TCHAR so I can
use it in the function.

TIA
Jul 19 '05 #1
7 20883

"ree" <re*@hotmail.coom> wrote in message news:Xn****************************@210.49.20.254. ..
I need to use a function from a wininet library, it requires the use of
const TCHAR.
The problem is the value needs to be calculated, so at the end I have this
string but I am having troubles converting it into a const TCHAR so I can
use it in the function.


TCHAR is a microsoft specific typedef for either char or wchar_t (or perhaps
unsigned short knowing these clowns). It's a single character, not a string.
You'd be better off asking on microsoft.public.vc.mfc but show a better example
there of what you are trying to do.
Jul 19 '05 #2
ree
"Ron Natalie" <ro*@sensor.com> wrote in
news:3f*********************@news.newshosting.com:

TCHAR is a microsoft specific typedef for either char or wchar_t (or
perhaps unsigned short knowing these clowns). It's a single
character, not a string. You'd be better off asking on
microsoft.public.vc.mfc but show a better example there of what you
are trying to do.

oops sorry its actually a static TCHAR[]....eg.

static TCHAR hdrs[] = _T("Content-Type: application/x-www-form-rlencoded");
Jul 19 '05 #3
> > TCHAR is a microsoft specific typedef for either char or wchar_t (or
perhaps unsigned short knowing these clowns). It's a single
character, not a string. You'd be better off asking on
microsoft.public.vc.mfc but show a better example there of what you
are trying to do.


oops sorry its actually a static TCHAR[]....eg.

static TCHAR hdrs[] = _T("Content-Type:

application/x-www-form-rlencoded");

At this juncture we frequently find ourselves reminding newbies...

- try on news:microsoft.public.vc.mfc

- learn C++ first before learning MFC. (MS should
have followed that one.)

- try on news:microsoft.public.vc.mfc

- don't use TCHAR unless you intend to turn on the
magic UNICODE option, which you probably won't.

- try on news:microsoft.public.vc.mfc

- Use a CString. It will match TCHAR's type, and
it has the common set of string operations

- try on news:microsoft.public.vc.mfc

- post some of /your/ code - we know what a
TCHAR looks like

- try on news:microsoft.public.vc.mfc

- if you absolutely must use std::string, yield its
char const * using myString.c_str()

- try on news:microsoft.public.vc.mfc

Are you starting to see any subtle hints in my post?

--
Phlip
http://www.greencheese.org/BrunoTheBandit
-- The smoker you drink, the programmer you get --
Jul 19 '05 #4
ree
"Phlip" <ph*******@yahoo.com> wrote in news:5wmkb.12781$u6.4228
@newssvr33.news.prodigy.com:


- learn C++ first before learning MFC. (MS should
have followed that one.)
- don't use TCHAR unless you intend to turn on the
magic UNICODE option, which you probably won't.

- try on news:microsoft.public.vc.mfc

- Use a CString. It will match TCHAR's type, and
it has the common set of string operations
- post some of /your/ code - we know what a
TCHAR looks like
- if you absolutely must use std::string, yield its
char const * using myString.c_str()


I am not sure if the problem is entirely TCHAR, it was just that I
didn't how to get a string variable into a constant expression. I just
thought there is something I am missing. Anyway I will try the ms
newsgroup.

Here is an example...
----------
static TCHAR frmdata2[] = _T("action=checkpassword&new_loc=%2Fbin");
I need to get the string variable in there
i.e
static TCHAR frmdata2[] = _T(string_variable);

Jul 19 '05 #5
> > - try on news:microsoft.public.vc.mfc

- if you absolutely must use std::string, yield its
char const * using myString.c_str()


I am not sure if the problem is entirely TCHAR, it was just that I
didn't how to get a string variable into a constant expression. I just
thought there is something I am missing. Anyway I will try the ms
newsgroup.

Here is an example...
----------
static TCHAR frmdata2[] = _T("action=checkpassword&new_loc=%2Fbin");
I need to get the string variable in there
i.e
static TCHAR frmdata2[] = _T(string_variable);


The function you want to call does not care about the 'static' or [], so you
could just pass string_variable.c_str() directly into that function. You
have copied example code and tried to change it without understanding it
first.

Try this question on news:microsoft.public.vc.mfc . But read a book about
C++. Asking this newsgroup to spoon-feed you the most basic things about how
the language works wastes both your time and ours.

--
Phlip
Jul 19 '05 #6
ree
"Phlip" <ph*******@yahoo.com> wrote in
news:9D*****************@newssvr17.news.prodigy.co m:


The function you want to call does not care about the 'static' or [],
so you could just pass string_variable.c_str() directly into that
function. You have copied example code and tried to change it without
understanding it first.


I tried what you said but it just gives me an error

error C2664: 'HttpSendRequestA' : cannot convert parameter 4 from 'const
char *' to 'void *'

Jul 19 '05 #7
ree
ree <re*@hotmail.coom> wrote in news:Xns94199B34941A0reehotmailcoom@
210.49.20.254:
"Phlip" <ph*******@yahoo.com> wrote in
news:9D*****************@newssvr17.news.prodigy.co m:

Dont worry found another way to do it. Thanks for all your help.
Jul 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Ben | last post by:
Hi all, I would like to know if there is an easy way to assign a string to an int. I have a struct such as: struct Values { int a; int b; }
8
by: Duncan Winn | last post by:
I am new to VC++7. I am using a method GetPrivateProfileString that requires an LPTSTR. I have defined this as a: char * data_name; I am then trying to convert this to an LPOLESTR and I...
8
by: Fred Hebert | last post by:
I have a function that requires a LPCTSTR parameter. I have the value I want to pass to it in a TextBox->Text field. Is there any way to do it in a single assignment. e.g. DWORD...
12
by: babak | last post by:
Hi everyone I want to format a string (using sprintf) and put it in a messagebox but however I try to do it, it doesn't seem to work. Here is an example sample of what i try to do: char msg;...
5
by: PaulH | last post by:
I have a function that is stripping off some XML from a configuration file. But, when I do a search for the pieces I want to strip, the std::string::find() function always returns std::string::npos...
3
by: Kevin Frey | last post by:
I am porting Managed C++ code from VS2003 to VS2005. Therefore adopting the new C++/CLI syntax rather than /clr:oldSyntax. Much of our managed code is concerned with interfacing to native C++...
14
by: =?Utf-8?B?Sm9hY2hpbQ==?= | last post by:
I have seen the following function to convert from a System::String^ to a const wchar_t*. I would like to get a LPCTSTR and AFAIK LPCTSTR is equal to const wchar_t*. Then it should all work right?...
14
by: Mosfet | last post by:
Hi, what is the most efficient way of doing a case insensitive comparison ? I am trying to write a universal String class and I am stuck with the case insensitive part : TCHAR is a char in...
4
by: David | last post by:
Hello, Looking for a solution to take something like: const TCHAR StrArrayZ=_T("Item1\0Item2\0Item3\0"); and convert it to something like: #include <align1.h>
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.