could u plz give 4 little files-sample (c and c++ code and header files) which shows how to call c++ class public member function.

thanx.

You write a C callable wrapper that runs the method.

#include <cstring>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

class Split {
  vector<string> result;
public:
  Split( const string& s ) {
    stringstream sin( s );
    string temp;

    while ( sin >> temp ) {
      result.push_back( temp );
    }
  }

  vector<string> Result() const { return result; }
};

extern "C" {
  char **SplitString( const char *s ) {
    vector<string> temp = Split( s ).Result();
    char **result = new char*[temp.size() + 1];

    // Terminate the result array with a sentinel.
    result[temp.size()] = 0;

    for ( vector<string>::size_type i = 0; i < temp.size(); ++i ) {
      // Add a new C-string to the result array
      result[i] = new char[temp[i].length() + 1];

      // Initialize the new string from the temp result
      strcpy( result[i], temp[i].c_str() );
    }

    return result;
  }
}
#include <stdio.h>

extern char **SplitString( const char *s );

int main( void ) {
  char **p = SplitString( "this is a test" );

  while ( *p ) {
    printf( "%s\n", *p++ );
  }

  return 0;
}
This question has already been answered. Start a new discussion instead.