import 'package:ffi/ffi.dart';
import 'dart:io' show Platform;
// C string parameter pointer function - char *reverse(char *str, int length);
typedef reverse_func = Pointer<Utf8> Function(Pointer<Utf8> str, Int32 length);
typedef Reverse = Pointer<Utf8> Function(Pointer<Utf8> str, int length);
main() {
var path = './structs_library/libstructs.so';
if (Platform.isMacOS) path = './structs_library/libstructs.dylib';
if (Platform.isWindows) path = r'structs_library\Debug\structs.dll';
final dylib = DynamicLibrary.open(path);
final reversePointer = dylib.lookup<NativeFunction<reverse_func>>('reverse');
final reverse = reversePointer.asFunction<Reverse>();
final reversedMessage = Utf8.fromUtf8(reverse(Utf8.toUtf8('backwards'), 9));
print('$reversedMessage');
}| Could you provide me with an example to pass a string to a native c function? Thanks |