CString to const *char or clr
-
Hello, Can someone please tell me how to convert from CString to const* char? I used the following from msdn website:
// Convert to a char* const size_t newsize = 100; char nstring[newsize]; strcpy_s(nstring, orig); strcat_s(nstring, " (char *)"); cout << nstring << endl;
But it requires that I compile with clr. When I do that, my classx.cpp (all my class function) are considered errors. When I don't modify the property of my solution to clr, I still get two errors:fatal error C1190: managed targeted code requires a '/clr' option
Is there any other way to convert without using clr? Thank you. --Star -
Hello, Can someone please tell me how to convert from CString to const* char? I used the following from msdn website:
// Convert to a char* const size_t newsize = 100; char nstring[newsize]; strcpy_s(nstring, orig); strcat_s(nstring, " (char *)"); cout << nstring << endl;
But it requires that I compile with clr. When I do that, my classx.cpp (all my class function) are considered errors. When I don't modify the property of my solution to clr, I still get two errors:fatal error C1190: managed targeted code requires a '/clr' option
Is there any other way to convert without using clr? Thank you. --StarThis is not clr code, I can't imagine how it gives you this error. The CString class has a GetBuffer method that returns a char *. Not sure if it is char or TCHAR, but so long as you're not building Unicode, they are the same.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Hello, Can someone please tell me how to convert from CString to const* char? I used the following from msdn website:
// Convert to a char* const size_t newsize = 100; char nstring[newsize]; strcpy_s(nstring, orig); strcat_s(nstring, " (char *)"); cout << nstring << endl;
But it requires that I compile with clr. When I do that, my classx.cpp (all my class function) are considered errors. When I don't modify the property of my solution to clr, I still get two errors:fatal error C1190: managed targeted code requires a '/clr' option
Is there any other way to convert without using clr? Thank you. --StarHi, Why dont you use the "strcpy" and "strcat" respectivily instead of using "strcpy_s" and "strcat_s". Since the later 2 functions have more securuty enchancements you problem could be related with that.
Manoj Never Give up
-
Hello, Can someone please tell me how to convert from CString to const* char? I used the following from msdn website:
// Convert to a char* const size_t newsize = 100; char nstring[newsize]; strcpy_s(nstring, orig); strcat_s(nstring, " (char *)"); cout << nstring << endl;
But it requires that I compile with clr. When I do that, my classx.cpp (all my class function) are considered errors. When I don't modify the property of my solution to clr, I still get two errors:fatal error C1190: managed targeted code requires a '/clr' option
Is there any other way to convert without using clr? Thank you. --StarIn addition to previous reply, have a look at
CString::operator LPCTSTR
. Again, it depends on project settings.
Prasad MS MVP - VC++
-
Hi, Why dont you use the "strcpy" and "strcat" respectivily instead of using "strcpy_s" and "strcat_s". Since the later 2 functions have more securuty enchancements you problem could be related with that.
Manoj Never Give up
manojkumarrai wrote:
Why dont you use the "strcpy" and "strcat" respectivily instead of using "strcpy_s" and "strcat_s".
I guess, one should always use enhanced versions of functions. Isn't it ?
manojkumarrai wrote:
have more securuty enchancements you problem could be related with that.
:confused:. How could be that ?
Prasad MS MVP - VC++