Sign in to follow this  
mgattala

problem with wcslen String ^ to char *

Recommended Posts

Hi all , I have some peice of code which is working fine and an analogous code in the same fine returning errors.. working code : pin_ptr<const wchar_t> file_x= PtrToStringChars(path); char * file = new char(wcslen(file_x)+1); int t= 0 ; while(file_x[t]!= '\0') { file[t] = (char)file_x[t]; ++t; } failing code : String^ valuefromc_seed ; valuefromc_seed = gcnew String(Y); (y is defined in a dll using c file) pin_ptr<const wchar_t> seed_x= PtrToStringChars(valuefromc_seed); char * seed = new char(wcslen(seed_x)); int u= 0 ; while(seed_x[u]!= 'm') { seed[u] = (char)seed_x[u]; ++u; } Its precisely failing at char * seed = new char(wcslen(seed_x)); .. it says head corruption... anyone has any input on this ? I need to use wcslen cos , i am using express edition 2008 ...with no marhsalling package.. thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this