Skip to content

Instantly share code, notes, and snippets.

@Axmill
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Axmill/394a4f577b0ee98465a5 to your computer and use it in GitHub Desktop.
Save Axmill/394a4f577b0ee98465a5 to your computer and use it in GitHub Desktop.
The C++ File & Python File
/* If you are wondering why there is C++ code in a C lib, it is because
* C does not offer good string support, so C++ code is needed to mani-
* pulate strings without implementing a whole bunch of code.
*/
#include <string>
#include <iostream>
using namespace std;
extern "C"
{
#include "stringManipulation.hpp"
#include <stdlib.h>
string string1;
string string2;
string concatenatedString;
//add more strings if needed
//creating refs
string& str1 = string1;
string& str2 = string2;
string& conStr = concatenatedString;
string concatString(string& str1, string& str2)
{
conStr = str1 + str2;
return conStr;
}
}
import ctypes
interfaceLib = ctypes.CDLL('Shared_Lib/bin/Library/libShared_Lib.so')
interfaceLib.test()
str1 = "H"
str2 = "I"
text = interfaceLib.concatString(str1, str2)
print(text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment