<!--
{
  "availability" : [
    "iOS: 2.0.0 - 2.0.0",
    "iPadOS: 2.0.0 - 2.0.0",
    "swift: -",
    "tvOS: 9.0.0 - 9.0.0",
    "visionOS: 1.0.0 - 1.0.0",
    "watchOS: 2.0.0 - 2.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSString/init(CString:)-vkuo",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSString(im)initWithCString:::SYNTHESIZED::c:objc(cs)NSString"
  },
  "title" : "init(CString:)"
}
-->

# init(CString:)

Initializes the receiver, a newly allocated `NSString` object, by converting the data in a given C-string from the default C-string encoding into the Unicode character encoding.

```
convenience init?(CString bytes: UnsafePointer<CChar>)
```

## Discussion

`cString` must be a zero-terminated C string in the default C string encoding, and may not be `NULL`. Returns an initialized object, which might be different from the original receiver.

To create an immutable string from an immutable C string buffer, do not attempt to use this method. Instead, use [`init(CStringNoCopy:length:freeWhenDone:)`](/documentation/Foundation/NSString/init(CStringNoCopy:length:freeWhenDone:)-86dm2).

## See Also



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)