From 3dd39f14f2806732f4218fa76706165ec789c1fe Mon Sep 17 00:00:00 2001 From: snarlferb Date: Mon, 5 Aug 2024 18:44:54 -0400 Subject: [PATCH] Anar --- vac.html | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/vac.html b/vac.html index 26acc19..7a842f1 100644 --- a/vac.html +++ b/vac.html @@ -48,7 +48,7 @@ It sounds more complicated than it is, since its describing multiple scenarios, however you can take it from the last scenario, and sortve trace the steps backwards so to speak... -The last scenario, we said we could take that `(*database>pack)` to access the `buffer` member of the `Anar` struct. +The last scenario, we said we could take that `(*database->pack)` to access the `buffer` member of the `Anar` struct. In C, when you mix (.) period and (->) arrow operators with dereferencing, parentheses adheres the order of operations. Without parentheses, you can’t directly use the (.) operator on a pointer without first dereferencing it. @@ -56,11 +56,13 @@ For example, consider *database->pack.nar.buffer Here’s how the C compiler interprets it: `database->pack` is a pointer to Vac. -`database->pack.nar` is an invalid syntax because (->) should be used for accessing members from a pointer -to a struct, and `nar` is not a member of ` Vac * ` but of `Vac` +`database->pack.nar` is an invalid syntax. -To correctly access buffer, you need to dereference `database->pack` to get the `Vac` struct. -Access the `nar` member of the `Vac` struct. And access the `buffer` member of the `Anar` struct (as we said when describing the last scenario) +First, (->) is used for accessing members from a pointer to a struct. And we want to use `nar`, however is not a member +of ` Vac * `. It is a member of `Vac`. + +We have to correctly access `buffer` of the `Anar` struct, and `nar` from the rest, you need to dereference +`database->pack` to get the `Vac` struct. Once you understand that, it should make sense. So the correct syntax in that particular situation would be: @@ -71,5 +73,4 @@ Vac *exac = *database->pack; -Which would allow you to use it as `exac->nar.buffer` - +Which would allow you to use it as `exac->nar.buffer`, and is just one example of something you might do.