---
title: lossyCString()
framework: foundation
role: symbol
role_heading: Instance Method
path: foundation/nsstring/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.

## Declaration

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

## Discussion

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(_:) if it needs to store the C string outside of the autorelease context in which the C string is created.

## See Also

### Related Documentation

- [cString(using:)](foundation/nsstring/cstring(using:).md)
- [data(using:allowLossyConversion:)](foundation/nsstring/data(using:allowlossyconversion:).md)

### Deprecated

- [string(withCString:)](foundation/nsstring/string(withcstring:).md)
- [init(CString:)](foundation/nsstring/init(cstring:)-vkuo.md)
- [string(withCString:length:)](foundation/nsstring/string(withcstring:length:).md)
- [init(CString:length:)](foundation/nsstring/init(cstring:length:)-5ure3.md)
- [init(CStringNoCopy:length:freeWhenDone:)](foundation/nsstring/init(cstringnocopy:length:freewhendone:)-86dm2.md)
- [string(withContentsOfFile:)](foundation/nsstring/string(withcontentsoffile:).md)
- [init(contentsOfFile:)](foundation/nsstring/init(contentsoffile:).md)
- [string(withContentsOf:)](foundation/nsstring/string(withcontentsof:).md)
- [init(contentsOfURL:)](foundation/nsstring/init(contentsofurl:).md)
- [write(toFile:atomically:)](foundation/nsstring/write(tofile:atomically:).md)
- [write(to:atomically:)](foundation/nsstring/write(to:atomically:).md)
- [getCharacters(_:)](foundation/nsstring/getcharacters(_:).md)
- [cString()](foundation/nsstring/cstring().md)
- [cStringLength()](foundation/nsstring/cstringlength().md)
- [getCString(_:)](foundation/nsstring/getcstring(_:).md)
