From 95eb711ca8c0843ede117f61025c5eda0102f845 Mon Sep 17 00:00:00 2001
From: Dave Gauer
- String literals are single-item constant {#link|Pointers#} to null-terminated byte arrays.
+ String literals are constant single-item {#link|Pointers#} to null-terminated byte arrays.
The type of string literals encodes both the length, and the fact that they are null-terminated,
and thus they can be {#link|coerced|Type Coercion#} to both {#link|Slices#} and
{#link|Null-Terminated Pointers|Sentinel-Terminated Pointers#}.
@@ -1783,7 +1783,7 @@ comptime {
expect(message.len == 5);
}
-// A string literal is a pointer to an array literal.
+// A string literal is a single-item pointer to an array literal.
const same_message = "hello";
comptime {
@@ -1989,15 +1989,15 @@ test "null terminated array" {
{#header_open|Pointers#}
- Zig has two kinds of pointers:
+ Zig has two kinds of pointers: single-item and many-item.
These types are closely related to {#link|Arrays#} and {#link|Slices#}:
-
-
When importing C header files, it is ambiguous whether pointers should be translated as - single-item pointers ({#syntax#}*T{#endsyntax#}) or unknown-length pointers ({#syntax#}[*]T{#endsyntax#}). + single-item pointers ({#syntax#}*T{#endsyntax#}) or many-item pointers ({#syntax#}[*]T{#endsyntax#}). C pointers are a compromise so that Zig code can utilize translated header files directly.
{#syntax#}[*c]T{#endsyntax#} - C pointer.