Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1272
  • Last Modified:

How to convert string to char[] in C++ 2008

I have a array char c[256]

How to convert txtbox1->Text to c[]?

Thank you. The environment is c++2008
0
xuanspider
Asked:
xuanspider
  • 3
  • 2
1 Solution
 
alb66Commented:
char* pText = Marshal::StringToHGlobalAnsi( txtbox1->Text );
strcpy( c, pText );
Marshal::FreeHGlobal( pText );
0
 
xuanspiderAuthor Commented:
IntPtr can not convert to char *, my environment is .net 2008
0
 
alb66Commented:
I forgot two cast...

char* pText = (char*)Marshal::StringToHGlobalAnsi( txtbox1->Text );
strcpy( c, pText );
Marshal::FreeHGlobal( (IntPtr)pText );
0
 
xuanspiderAuthor Commented:
I'm sorry that still cannot, same error. Please note that the environment is C# express 2008
0
 
xuanspiderAuthor Commented:
Anyhow, thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now