CString
-
C++ has several utilities to manipulate strings declared as char var;, i.e. strncpy(a,b,n); where a,b are strings, n is the number of characters, etc. However, when one declares a variable as a CString, and uses the same utility, the compiler says that it cannot convert the CString to a char variable. Are there other C++ or visual C++ 6.0 utilities to work with CString variables? Please provide help on this subject. Thanks, Sid Kraft
Sid
-
C++ has several utilities to manipulate strings declared as char var;, i.e. strncpy(a,b,n); where a,b are strings, n is the number of characters, etc. However, when one declares a variable as a CString, and uses the same utility, the compiler says that it cannot convert the CString to a char variable. Are there other C++ or visual C++ 6.0 utilities to work with CString variables? Please provide help on this subject. Thanks, Sid Kraft
Sid
When you need a const string you can use a CString directly. When it's being used in a non-const fashion, use CString::GetBuffer. char *strncpy( char *strDest, const char *strSource, size_t count ); (i.e. Here you can use CString as is for the second parameter since the LPCTSTR operator kicks in. If you use CString for the first parameter, you need it to be non-const. In other words, you need a buffer, so use CString::GetBuffer as the first parameter and later calling CString::ReleaseBuffer before calling any other CString member functions.)
-
C++ has several utilities to manipulate strings declared as char var;, i.e. strncpy(a,b,n); where a,b are strings, n is the number of characters, etc. However, when one declares a variable as a CString, and uses the same utility, the compiler says that it cannot convert the CString to a char variable. Are there other C++ or visual C++ 6.0 utilities to work with CString variables? Please provide help on this subject. Thanks, Sid Kraft
Sid
cast it to (LPTSTR)(LPCTSTR)CString Object
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
-
cast it to (LPTSTR)(LPCTSTR)CString Object
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
That has to be a joke.
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ I work for Keyser Söze
-
That has to be a joke.
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ I work for Keyser Söze
Michael Dunn wrote:
That has to be a joke.
thats the great mistake i have done!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
-
Michael Dunn wrote:
That has to be a joke.
thats the great mistake i have done!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
But why great mistake?;);P
-
C++ has several utilities to manipulate strings declared as char var;, i.e. strncpy(a,b,n); where a,b are strings, n is the number of characters, etc. However, when one declares a variable as a CString, and uses the same utility, the compiler says that it cannot convert the CString to a char variable. Are there other C++ or visual C++ 6.0 utilities to work with CString variables? Please provide help on this subject. Thanks, Sid Kraft
Sid
sidkraft wrote:
However, when one declares a variable as a CString, and uses the same utility...
And why in the world would you want to do that?
sidkraft wrote:
Are there other C++ or visual C++ 6.0 utilities to work with CString variables?
They are called methods, and
CString
has plenty of them.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne