On Tue, Feb 16, 2021 at 12:45 PM Mark Filipak (ffmpeg) <markfili...@bog.us> wrote: > > On 02/15/2021 06:47 PM, Chris Angelico wrote: > > On Tue, Feb 16, 2021 at 8:44 AM Mark Filipak (ffmpeg) > > <markfili...@bog.us> wrote: > >> > >> On 02/15/2021 04:32 PM, Carl Zwanzig wrote: > >>> On 2/15/2021 1:26 PM, Mark Filipak (ffmpeg) wrote: > >>>> Yes, I'm aware of C++. It's sort of a 'C' language architecture hack, > >>>> isn't it? > >>> More like butchery ... > >> > >> Ooooo... that's harsh. :-) > >> > >>> Glad it's making more sense now. > >>> > >>> z! > >> > >> Thanks for the confirmation. Now, regarding pointers-to-pointers and '*' > >> as a unary operator..... > >> > > > > A pointer, at its core, is a number representing a place in memory. A > > pointer to a pointer is a number representing the place in memory > > where you can find another number that'll tell you where you want to > > go. You want to know where the Sword Master can be found, but I won't > > tell you where he is; all I'll tell you is that the shopkeeper knows > > where to find the Sword Master. I point you to the shopkeeper, and > > then you ask him to point you to the Sword Master. > > > > The asterisk, as a unary operator, is one step in that process. > > Something like this: > > > > int **trial = find_sword_master(); > > Oops, I'm getting lost in the story of the Sword Master. You're describing > indirection. I have no > problem with indirection. The problem I have is simply with syntax > interpretation because to me, > every variable (or constant) in every language is a location in memory, so > when you write that a > number represents a place in memory, to me it's undistinguished, it's not any > different than any > other variable (in any location in memory). > > Does '*' (a unary operator) that precedes a variable's name indicate that the > named variable is a > pointer? Or do I have that bit wrong?
Yes, it does. For "*trial" to be meaningful, "trial" has to be a pointer. > Is '**' also a unary operator? Or is it 2 unary operators, '*'+'*'? I suspect > that '**' is the > infamous pointer-to-pointer (i.e. doubly indirect), or do I have that bit > wrong? It's two separate unary operators, which is why I wrote it in one place as *(*trial) - has the same meaning. Yes, "**trial" implies that trial is a pointer to a pointer. > > "trial" is a number that says where in memory the shopkeeper is. > > What's that number? > > > > printf("Shopkeeper is at %p\n", trial); > > I have no idea what '%p' means or what you're trying to demonstrate by the > code. I don't know why > the printf has a 2nd arg: 'trial'. '%' is modulo, but modulo is a binary > operator, not a unary > operator. That it's in a string just adds to the mystery. Ah, printf is doing formatted output, so it interpolates a value. Sorry, if you're not familiar with that, just ignore it. > > "*trial" is the number that can be found there. What's that number? > > > > printf("Sword Master is at %p\n", *trial); > > Okay, now I'm lost. is 'trial' a variable or a pointer? Both. In the same way that "int x = 5;" has x as a variable and an integer. > Specifically, is '*trial' a pointer that's > labeled "trial" or is it a pointer to a variable that's labeled "trial"? It's a pointer that's labelled "trial". The name refers to the variable that has the first pointer - or if you prefer, it refers to the variable that has the address of the second step. > Or are both labeled > "trial"? Or does the string "*trial" just represent an entity that's just a > relative memory address > that neither the compiler nor the runtime system normally discloses? If your > 'printf' functions > print, what do they print? ...Yes, I know that 'print' doesn't mean print on > a printer. The only > thing I can guess is that "%p" is some sort of token, but I don't know its > meaning. Don't worry about the printf stuff, that's just a quick way to print out the numbers involved. > The rest of 'C' syntax, and precedent, and operators, etc. I know. It's just > pointers that mystify > me. Now I understand what a struct actually is but pointers?... not so much. > I thought I understood, > but '**' fuddled it. I'm afraid I'm one of the people who, for example, > actually prefer BNF to > textual descriptions. > A pointer, ultimately, is just a number - the address of the next thing. So the pointer-to-pointer is saying "at this address, you can find the address you want". If this isn't helpful, feel free to ignore it; I'm sure there's BNF around somewhere to explain it, but I'm not sure I could write it that way, sorry. ChrisA _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".