Data type conversion from Window Form to Win32 console app

Hello Everyone, I am quite new to C++. I have some experience already with using console applications and I have used that app to design a project using int, long and char* data types. I have now designed a Window form app to take the data needed by the console app, but after importing all the header and source files I used for the console app into the Windows form app, it brings up the error C2664 (cannot convert System::String ^ to char*). Please how can I resolve this issue, cause I am still very new to designing software. Thanks
Last edited on
Probably like this, str.c_str() but of course it depends on the context as to whether this is appropriate or relevant.
Hello Chervil, thanks so much for your reply. I'm sorry it took a while to get back, it was becuse I had a very tight weekend. I have already tried to use this c_str() method, but it brings up two C2039 errors (strcpy is not a member of std and c_str() is not a member of System::String).

Maybe I should explain myself in better detail, I initially used a console app to design how the data (using the int, long and char* data types) received should be processed and I used the cin and cout to have it tested and it worked fine. Now, I have made a Windows form application which uses the strings written in the Textboxes of the form to obtain the data required by the console app which is now incorporated in the Windows form app by adding the header and source files of the initial app.

I am making the data conversion to take place just after an OK button is pressed in the form, so the process to carry out this conversions are done in the code section of the form's header file.

I have been able to convert the String ^ data type to int data type by using the Int32::Parse() method, but The main problem now is how to convert the strings in String^ data type to char* data type that is used by the console app.

Thanks so much and any suggestion will be greatly appreciated.
Last edited on
I think this is what you want:

while ansi is not necessarily console.

you can access the console with .net as well:
I was thinking of the C++ std::string. The System::String referred to is something different. This page may help:
Thanks guys,

I was able to resolve it using the first webpage provided by Coder777. Chevril, I also had a look t the page you provided, but I got very confused because I'm still very new to using c++ for a software application.

I'm actually into hardware design, and it is in those areas I have implemented C++, but now the project I'm working on requires me to build a database app, which is very complicated, and that is why I joined this forum.

Thanks once again.
Topic archived. No new replies allowed.