Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
char **details;
    list->Add(gcnew String("Test String 1"));
    list->Add(gcnew String("Test String 2"));
    list->Add(gcnew String("Test String 3"));

    String^ filterTxt = "two";

    for(int i=0;i<3; i++)
    {
        details[i]=(char*)(void*)Marshal::StringToHGlobalAnsi(list[i]);
        Console::WriteLine(details[i]);
    }
    Console::ReadLine();



The above code getting the null reference exception, please help me on this.
Posted

1 solution

Well, perhaps, if you assigned some actual memory to details the error would go away?

You declared it as a pointer-to-pointer-to char:
C++
char **details;
And the next thing you do with it is try to fill it up:
C++
details[i]=(char*)(void*)Marshal::StringToHGlobalAnsi(list[i]);
At no point do you actually point it at anything...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900