---
title: "getCString(_:maxLength:encoding:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/stringprotocol/getcstring(_:maxlength:encoding:)"
---

# getCString(_:maxLength:encoding:)

Converts the String’s content to a given encoding and stores them in a buffer.

## Declaration

```swift
func getCString(_ buffer: inout [CChar], maxLength: Int, encoding: String.Encoding) -> Bool
```

## Discussion

Discussion note: Will store a maximum of min(buffer.count, maxLength) bytes.
