<!--
{
  "availability" : [
    "iOS: 2.0.0 - 2.0.0",
    "iPadOS: 2.0.0 - 2.0.0",
    "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/lossyCString()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSString(im)lossyCString"
  },
  "title" : "lossyCString()"
}
-->

# lossyCString()

Returns a representation of the receiver as a C string in the default C-string encoding, possibly losing information in converting to that encoding.

```
func lossyCString() -> UnsafePointer<CChar>?
```

## Discussion

This method does not raise an exception if the conversion is lossy. The returned C string will be automatically freed just as a returned object would be released; your code should copy the C string or use [`getCString(_:)`](/documentation/Foundation/NSString/getCString(_:)) if it needs to store the C string outside of the autorelease context in which the C string is created.

## See Also

[`-  cStringUsingEncoding:`](/documentation/Foundation/NSString/cString(using:))

Returns a representation of the string as a C string using a given encoding.

[`-  dataUsingEncoding:allowLossyConversion:`](/documentation/Foundation/NSString/data(using:allowLossyConversion:))

Returns an `NSData` object containing a representation of the receiver encoded using a given encoding.



---

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)