I have some code to convert from Obj C to Swift, which involves strncpy
.
The original Obj C code:
const char * c_amount = [[NSString stringWithFormat:@"%08d", (int)([amount floatValue])] UTF8String];
strncpy(request.amount, c_amount, (unsigned int)sizeof(request.amount));
What I've tried on Swift:
let c_amount = String(format: "%08d", Int(CFloat(amount))).utf8
strncpy(request.amount, c_amount, UInt(sizeof(request.amount)))
But this gives me error:
Cannot convert value of type '(Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8)' to expected argument type 'UnsafeMutablePointer<Int8>'
I don't actually understand how to fix the error at all, as I rarely working with pointer on Swift. Can somebody help?