assign a CString to a char *

T

Toro

1) say,

CString b;
char * a;

how do I assign b into a ?
strcpy(a,b) has no problem in compiling but I don't get what I want.

2) I used
char ** argv
to get input from the console and I can get back int or char * . But how can
I do the reverse ? (Assigning variables of type int and char * into a char
**)

Thanks!
 
J

Jumbo

Toro said:
1) say,

CString b;
char * a;

how do I assign b into a ?
strcpy(a,b) has no problem in compiling but I don't get what I want.

2) I used
char ** argv
to get input from the console and I can get back int or char * . But how can
I do the reverse ? (Assigning variables of type int and char * into a char
**)

Thanks!
Sorry CString is off topic.

MSDN....CString theString( "This is a test" );
LPTSTR lpsz = new TCHAR[theString.GetLength()+1];
_tcscpy(lpsz, theString);
//... modify lpsz as much as you want
 
J

Jorge Rivera

Toro said:
Please, I am writing a MFC application.
He just gave you the answer, stop whining.

You can also try.

CString cstr("Garbage");

// Makes a copy of the buffer in the string
char* buf = cstr.GetBuffer(cstr.GetLength());

// Do this after you are done using your char* buffer
cstr.ReleaseBuffer();
 
T

Toro

CString cstr("Garbage");
// Makes a copy of the buffer in the string
char* buf = cstr.GetBuffer(cstr.GetLength());

// Do this after you are done using your char* buffer
cstr.ReleaseBuffer();

thanks, this one is more readable/understandable, the last one seems to be
words from MARS.
 
P

Paul

Toro said:
thanks, this one is more readable/understandable, the last one seems to be
words from MARS.
The first answer was correct. CString *is* off-topic for this newsgroup.
CString is an MFC class, and MFC is a proprietary Microsoft library.
Proprietrary libraries are off-topic to comp.lang.c++. This newsgroup
discusses standard C++, and CString is not standard C++.

Instead, you should direct your question concerning CString to a Micrsoft
newsgroup, not here.

Paul
 
J

Josh Lessard

Proprietrary libraries are off-topic to comp.lang.c++.
says who?

Says the topic of the newsgroup. It's *Standard* C++, and propriety
libraries (including Microsoft's MFC classes) are not part of Standard
C++...that makes them off-topic.

*****************************************************
Josh Lessard
M.Math Candidate
School of Computer Science
University of Waterloo (519)888-4567 x3400
http://www.cs.uwaterloo.ca
*****************************************************
 
M

Mike Wahler

Frank Puck said:
again says who?
A newsgroup is what its posters are.
You can ignore subjects or posters.
But cannot forbid subjects or posters.

When interacting with a group, one can either perform the
courtesy of observing the group's 'culture' and guidelines, or
be discourteous and ignore them. But be prepared for folks
to treat you as you've treated them.

-Mike
 
J

Jorge Rivera

Frank said:
again says who?
A newsgroup is what its posters are.
You can ignore subjects or posters.
But cannot forbid subjects or posters.

Listne, nobody is trying to put anybody else down (that's not really
true about everyone).

The truth is that the power of newsgroups is dilluted if you can't
narrow down the scope of the topics contained. If topics from a variety
of fields are discussed in the same newsgroup, the help anybody can
provide is marginal.

Anyway, you are correct, anybody can post whatever they feel like, but
it is just a matter of courtesy to try and find an appropriate newgroup
for your post, given the sheer amount of newsgroups available.

Jorge L.
 
F

Frank Puck

Mike Wahler said:
When interacting with a group, one can either perform the
courtesy of observing the group's 'culture' and guidelines, or
be discourteous and ignore them. But be prepared for folks
to treat you as you've treated them.


sorry I did not realize that you define who is comp.lang.c++
there is a reason why people post here instead of comp.lang.c++.moderated
-- one is that they don't want to be zensured
welcome in my killfile
 
M

Mike Wahler

Frank Puck said:
sorry I did not realize that you define who is comp.lang.c++

I don't. Years of convention have. This convention has
been codified in the 'welcome message' at the link I posted.
there is a reason why people post here instead of comp.lang.c++.moderated

The best rational reason I know of is that an unmoderated
group has quicker turnaround.
-- one is that they don't want to be zensured

Not a valid reason imo.
welcome in my killfile

Thank you.


-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,159
Messages
2,570,881
Members
47,418
Latest member
NoellaXku

Latest Threads

Top