From 2ccfd78f9417e53b539c145b6de727e28e5ce05b Mon Sep 17 00:00:00 2001 From: Stoyan Kostadinov Date: Sat, 13 Jul 2024 15:31:10 +0200 Subject: [PATCH] fix typos in print statements --- chapters/c.adoc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/chapters/c.adoc b/chapters/c.adoc index 8c6b105..b5c9de1 100644 --- a/chapters/c.adoc +++ b/chapters/c.adoc @@ -404,14 +404,14 @@ int main() { printf("\n This is arr[0]: %c ", arr[0]); printf("\n This is *arr: %c ", *(arr+0)); //as well as: - printf("\n This is arr[0]: %c ", arr[1]); - printf("\n This is *(arr+0): %c ", *(arr+1)); - printf("\n This is arr[1]: %c ", arr[2]); - printf("\n This is *(arr+1): %c ", *(arr+2)); - printf("\n This is arr[2]: %c ", arr[3]); - printf("\n This is *(arr+2): %c ", *(arr+3)); - printf("\n This is arr[3]: %c ", arr[4]); - printf("\n This is *(arr+3): %c ", *(arr+4)); + printf("\n This is arr[1]: %c ", arr[1]); + printf("\n This is *(arr+1): %c ", *(arr+1)); + printf("\n This is arr[2]: %c ", arr[2]); + printf("\n This is *(arr+2): %c ", *(arr+2)); + printf("\n This is arr[3]: %c ", arr[3]); + printf("\n This is *(arr+3): %c ", *(arr+3)); + printf("\n This is arr[4]: %c ", arr[4]); + printf("\n This is *(arr+4): %c ", *(arr+4)); //understanding that, you can see now why in C, a thing that looks very weird as the following, makes sense: printf("\n This is 1[arr]: %c ", 1[arr]); //As you see, it printed 'e', because that expression is just *(1+a), which is the same as *(a+1)