Solved

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

Posted on 2009-04-06
5
1,255 Views
Last Modified: 2012-05-06
I have a array char c[256]

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

Thank you. The environment is c++2008
0
Comment
Question by:xuanspider
  • 3
  • 2
5 Comments
 
LVL 19

Expert Comment

by:alb66
ID: 24075272
char* pText = Marshal::StringToHGlobalAnsi( txtbox1->Text );
strcpy( c, pText );
Marshal::FreeHGlobal( pText );
0
 

Author Comment

by:xuanspider
ID: 24075404
IntPtr can not convert to char *, my environment is .net 2008
0
 
LVL 19

Accepted Solution

by:
alb66 earned 250 total points
ID: 24077619
I forgot two cast...

char* pText = (char*)Marshal::StringToHGlobalAnsi( txtbox1->Text );
strcpy( c, pText );
Marshal::FreeHGlobal( (IntPtr)pText );
0
 

Author Comment

by:xuanspider
ID: 24083087
I'm sorry that still cannot, same error. Please note that the environment is C# express 2008
0
 

Author Closing Comment

by:xuanspider
ID: 31566924
Anyhow, thanks.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Deploying with installshield 1 360
Convert CString to String C++ 25 762
How to measure sizes and angles in scanned images ? 3 63
Resolve Dependency Issues 4 68
The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question