Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8264139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:21:09+00:00 2026-06-08T04:21:09+00:00

My c code is like void GetCharArray(char* arrayNew[5]) { arrayNew[0] = Test; arrayNew[1] =

  • 0

My c code is like

void GetCharArray(char* arrayNew[5])
{
    arrayNew[0] = "Test";
    arrayNew[1] = "Test2";
    arrayNew[2] = "Test4";
    arrayNew[3] = "Test5";
    arrayNew[4] = "Test6";
}

extern "C" __declspec(dllexport) void GetCharArray(char* arrayNew[5]);

I want to get the array populated with string in my C# code

[DllImport(@"C:/Test.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
public static extern void GetCharArray([MarshalAs(UnmanagedType.LPArray, SizeConst=5)] string[] sbOut);

List<string> testStr = new List<string>();
GetCharArray(test.ToArray());

I want my testStr to be populated with strings from C code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T04:21:10+00:00Added an answer on June 8, 2026 at 4:21 am

    found a solution

    public static extern void GetCharArray(IntPtr[] results);
    
    IntPtr[] pointers = new IntPtr[1000];
    GetCharArray(pointers);
    string[] results = new string[1000];
    for (int i = 0; i < 1000; i++)
    {
        results[i] = Marshal.PtrToStringAnsi(pointers[i]);
    }
    

    I hope it helps someone else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a test like: void TestSomething(int someParam) { // Test code }
I use to write code like this: void fun(char *buff, unsigned size) { std::strstream
Where I work, I often see code like that : public void Test(Models.User.UserInfo userInfo,
I have a code like void onDgvRelations_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.ColumnIndex ==
So i have some code like this: void foo (int, int); void bar (
I'm using boost::asio, and I have code like this: void CServer::Start(int port) { tcp::acceptor
I have code like this protected void rptCategory_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType
The basic pseudo code looks like this: void myFunction() { int size = 10;
How do you think about data access code like this: public void AddCusotmer(Cusotmer customer)
My code looks like below: private void LayoutRoot_Loaded(object sender, System.Windows.RoutedEventArgs e) { // TODO:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.