[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


Janitor application acceptance emails are being sent out. Please remember to check your spam box!


[Advertise on 4chan]


File: bug spray.png (6 KB, 728x200)
6 KB
6 KB PNG
>jeet somehow makes it through the HR filter
>have to waste part of my day interviewing a log of talking feces who got their degree by plagiarizing the work of other jeets - jeets who just used AI to generate it in the first place
>get all the obligatory parts of the interview out of the way
>time for the technical portion
>ask just one single question
what is this, and when might it be used?
>not a single jeet has made it through the pointer filter
you guys know how pointers work, right?
>>
pointer pointer pointer - i have no idea when i would need to use one. been programming for 30years now.
>>
>>107133306
this is like showing a picture of a man's ass and asking how it might used. i have no idea because i'm not a retarded fag.
>>
>>107133371
Sir you just won the interwebs
>>
>>107133306
>what is this, and when might it be used?
This is bad and it might be used by people who can't actually program. Show me 1 (ONE!) realistic use case for this.
>>
that's just a 3d jagged array what
>>
>>107133397
Use case for 3D jagged arrays of ints?
>>
>>107133306
>when might it be used

When you have a data structure that is 3-dimensional.
However, it is relevant to note that in many case, developers choose to flatten the data structure so that it becomes 1 dimensional.
One example is Java image. The data structure is 2d, but the underlying data is a 1d array.
>>
>>107133306
I couldn't grasp pointers until someone explained them as "it's just a variable that holds a memory address" and suddenly it made complete sense
>>
>>107133306
>int***
There is no use for this. It's 2025, there are better structures available saar.
>>
>>107133498
>it's just a variable that holds a memory address
That's literally not what it is, thoughbeit.
>>
>>107133424
finding linear gradients within a set of unknown size according to three distinct metrics. financial clients will buy anything.
>>
>>107133503
>there are better structures available
Available for doing what? Guaranteed this thread will die without an answer. /g/ is really just /fizzbuzz/ + /lgbt/.
>>
>>107133306
>jeets and triple pointers
guaranteed segfault
>>
what's the usecase for this? who is using pointers like this in 2025?
>>
>>107133523
>gradients
But it's a bunch of ints... Also you'd just use a float **.
>>
>>107133531
In my domain, usually a sparsely allocated array/table. But there's no reason to deal with this when standard library containers exist in basically every language worth using.
>>
>>107133554
i assumed the question was more about the 3 pointers and not so much the type they point to. in reality it's very rare to need more than one pointer because of sib addressing.
>>
>>107133306
i got once mocked for being a three star programmer
i could have done it with a two star pointer but it would have looked messier

https://wiki.c2.com/?ThreeStarProgrammer
>>
No, I don't and I don't have to. I'm the "IT guy" at work because I have basic Windows/Office skills.
I'm mainly on /g/ for tech news because I can't be bothered to go on a different website for that shit.
>>
>>107133517
it is
>>
It's for passing a dynamically allocated 2D array by pointer.
I wrote one of these recently for that reason.
What's my prize?
>>
>>107133657
an army of leetcode zoomers with a first year depth of knowledge and zero real world experience to shriek at you.
>>
>>107133498
That simplification leads to undefined behavior.
>>
>>107133306

int** matrixResult;
int** matrixA;
int** matrixB;

findSmallestMatrix(&matrixResult, matrixA, matrixB);

void findSmallestMatrix(int*** a, int** matrixA, int** matrixB){
int** smallestMatrix;
//code to find smallest matrix between matrixA and matrixB

*a = smallestMatrix;
}
>>
>>107133690
Thanks, it's what I always wanted.
>>
>>107133746
In such a case you'd probably use a typedef.
>>
>>107133920
hiding a triple pointer as a pointer to a double pointer type is still a triple pointer
>>
>>107133746
>double dereferencing for a 2d array
what? why?
allocate one contiguous area and use maths you dweeb
>>
>>107133920
i never typedef data structures. it only hides important details. typedefs are good for regulating what can and can't be passed to functions but that's about it.
>>
>>107133657
> 2-D array
Is that a row-major or column-major array?
> furiously googles
> fuuuuu
>>
I'm a hobbyist...

How often do 3d arrays pop up in the real world? I think I've only ever built one replicating Game of Life in the 2 years that I've been fooling around.
>>
>>107133654
You got filtered by pointers. Good job.
>>
>>107133986
i remember needing to look up something in the systemd source
they used triple pointers twice in the file i read
>>
>>107133986
They're quite common in games or anything that deals with anything 3D, but machine learning is absolutely full of tensors of all sorts of dimensions. Although you'd still always want to use contiguously allocated ones.
I've worked with a lot of volumetric stuff but I don't think I've once seen an int***a. This just looks like a cache miss hell to me. It might be some kind of hash table.
>>
>>107133711
user input is a undefined behavior
>>
>>107133986
I use 3D "logical" arrays in computer graphics. But it's really just a 1D array, you order shit by morton codes so its spatially close for cache speedups, and then use functions to from a 1D index to a 3D index and vice versa
>>
>>107133746
>int** matrixB;
why not int* matrixB; /* ?
>>
>>107134042
>>107134115
>>107134243
Thanks guys
>>
>>
>>
C++ can generate ass many copies of a function as many different array sizes used
>>
so the OP not any better than the jeet
>>
Would int******************** compile?
>>
>>107133498
it's just an index value that lets you index into the virtual memory array
this is the foundation of rust's "safety" btw. by transmuting all memory errors into logic errors.
>>
>>107134029
Jeet moment
>>
>>107133517
>>107133711
That is what it is. Just because you cannot do certain things with that address for retarded corner case compiler micro-optimizations and theoretical compatibility with obscure hardware from the 70s doesn't mean it isn't what it is conceptually and in 99% of cases how it's actually implemented.
>>
>>107133958
What if the component arrays frequently change in size? In that case you just played yourself.
>>
>>107133517
So many retards fall for it, it's unreal. I wish pointers could be replaced with the name handles so people would shut the fuck up.
>>
>>107134960
>>107135053
>80 IQ white trash on par with the average Indian get repeatedly filtered by an abstraction as basic as a fucking C pointer
>>
>>107135118
I have an idea, let's call them "references".
>>
>>107135118
>I wish pointers could be replaced with the name handles so people would shut the fuck up.
You can say a pointer is a handle. A handle is not necessarily a pointer, thoughbeit. How did every board on this site get this fucking bad?
>>
>>107135168
If you want to jerk off to abstractions go program in Haskell you pretentious faggot.
The whole point of C is that you can reasonably predict what the compiled code is going to look like.
>>
>>107133306
>still uses pointers for something solved by higher level datastructures like std::array, std::vector or Rust's slice and Vec type.
it's honestly pathetic this is the best "own" you got. frankly I don't know what use case I'd use for such a cursed type as I would have written this in C++ at a minimum before seeing even an int** a;
>>
>>107133554
>he doesn't compute "derivatives" on arrays of ints
biologer shoo this is a computer science graduate board
>>
>>107135168
Explain to us how pointers work then.
>>
>>107135196
>mentally ill /pol/tranny doesn't understand that a C pointer is an abstraction over memory addresses with a bunch of extra semantics that memory addresses lack
>>
>>107135168
most people on /g/ are. I am going to go back to another board.
>>
>print pointer
>literally an address
>>
File: 1760892451195416.jpg (27 KB, 461x461)
27 KB
27 KB JPG
>>107135241
>with a bunch of extra semantics that memory addresses lack
Midwit gibberish, especially when you consider that void* exists
>>
>>107135241
I've stayed out of this, but you are horrifically autistic. You're saying the same thing as them with more terse "c committee" style wording and human repellant personal charm.
>>
File: Terry_The_Terrible.jpg (46 KB, 500x500)
46 KB
46 KB JPG
>>107135234
>>107135287
Ok, let me dumb it down to your nonwhite level:
uint64 addr = YOUR_MOMS_HOUSE;
++addr;

House *ptr = (House*)address;
++ptr;

Incrementing the address gets me from your mom's living room to your mom's bedroom. Incrementing the pointer gets me to the neighbor's house when I'm done with her. This concludes today's lesson about pointers.
>>
>>107135341
You're confusing the pointer object with pointer types
>>
>>107135241
I think you need to take a step back and consider why you're apoplectic over some calling a pointer a variable.
>>
>>107135341
>the compiler treats each pointer type as a different type and applies pointer arithmetic to it differently
>therefore variables with a pointer type are not variables and don't (normally) hold memory addresses
legit 70IQ post
>>
>>107135365
You're a retard who can't grasp the difference between two basic concepts. There's no rhetoric that gets you around this.
>>
>>107135382
>a pointer is just a variable that holds an address
>a pointer has special semantics
Pick one and only one.
>>
>>107135383
a pointer is a variable. a pointer holds a memory address, or rather whatever it holds gets treated as a memory address. the C standard lets you imbue a pointer with type information but it's still a variable of a given type that, when dereferenced, tries to read (or call, if you've told the compiler that it's a function pointer) whatever the fuck is at a given memory address
>>
>>107135383
I think you may have 2 servings of math brain and only a spoon full of linguistics on the side. You have your specific way of understanding exactly what's happening on the metal, but won't suffer anyone describing the exact same thing in words that don't fit your understanding exactly.
>>
>>107135406
>a pointer is a variable.
True.
>a pointer holds a memory address
True.
>a pointer is just a variable that holds an address
Not true. No wonder Americoon white trash is getting replaced by jeets in every field. Imagine being THIS retarded.
>>
>>107135405
non-retarded people (not jeets like you) understand the english language well enough to grasp that the "just a variable that holds X" statement does not preclude special semantics, because all other types in the language can do more than just "hold X" - they've also got various operators defined on them
>>
>>107135383
>no u
I'll spell it out for you: the only thing that defines a pointer is the fact that it holds an address. Pointer arithmetic is done purely by the compiler, and it's not even enforced because type erasure exists
>>
>>107135415
see >>107135423

as is typical of the soulless bugman races, you are unable to grasp the fundamental semantics of the language you're using and relying on rote memorization of surface level grammar instead
>>
>>107135423
Please consult >>107135415. Notice how I've correctly determined your country of origin based on your behavioral patterns and mental deformities, meanwhile you're stuck flailing about imaginary jeets, which does absolutely nothing.
>>
>>107135444
>>107135428
Address this you jeet. Your autistic pointer definition prevents malloc from working in C
>>
>>107135462
Not reading any more Americoon psychotic rambling. See >>107135444
>>
>>107135503
I'm European thoughbeit
>>
>>107135512
>la creatura is still in the denial phase
Cute.
>>
File: 4x7en05jhuzf1.jpg (66 KB, 591x707)
66 KB
66 KB JPG
>>107135532
>IIT Bombay rote memorization gets exposed as ineffective, as always
>muh racemixed americans!!
Again, explain this
>>107135428
>>107135462
>>
>>107135423
It's unironically autism. Autists have trouble understanding communication that isnt extremely literal.
>>
>>107135557
Please consult >>107135444 as many times as it takes for Americoon reading comprehension to kick in. Repeating the same mistake won't get you far.
>>
>>107135598
That post didn't explain shit. You are literally wrong and can't even understand why. I'm not wasting my time here anymore
>>
>>107135596
I have no trouble understanding your retarded communication. You just have trouble understanding why an address is not a pointer even when I spell it out for you in the simplest way possible.
>>
fuck this i'm learning FP instead
>>
>>107135633
I understand why a pointer is not literally a variable with a memory address. They have different semantics so the distinction is trivially true before you even consider typing. most things are not literally identical to anything else.

I just think it's autistic to get this mad over handwaving them as the same thing when they're pretty damn close.
>>
>>107134490
seems like you can pile these on as much as you need
>>
I think the only time I'm doing double pointers explicitly are for cyclically dependent data structures which is something I try to refactor out if I can. As in A depends on B and B depends on A so you pass a double pointer of B when constructing A, or vice versa. Delay the expansion of the variable until its needed.
But again I try to factor situations like this out since usually things can be more simple and straight forward.

I don't know if I've ever needed an explicit triple pointer unless you count arrays in C maybe.
>>
>>107135673
>I understand why a pointer is not literally a variable with a memory address. They have different semantics so the distinction is trivially true
Very good. Now try telling it to the gaggle of mouth-breathers who get mad when you so much as use the word 'semantics'. And then try telling them that nowhere in the C standard does it even say the actual bit representation behind a function pointer has to be a RAM address, or that it has to be an address at all - for all you know, it could include some weird metadata needed to execute code on that particular architecture.
>>
>>107135341
So a pointer behaves differently than an in when you increment it. If we want to be autistic I have to point out that there isn't even a contradiction because noone said a pointer is an int, they only said it's a variable. That that should mean it increments like an int is your own baseless assumption.
>>
>>107135633
What do you want people to say?

It's a user friendly name assigned to a memory address that references another memory address that contains a particular size piece of information?

"Variable" just works.
>>
>>107135733
They said a pointer is "just" a variable that holds an address. Well, there you have a snippet with a variable that holds an address but it's not acting like a pointer. Oops? And I wasn't even lashing out for the naive anon who said it. I was just light-heartedly teasing him at first, but it inevitably ended up attracting a horde of know-nothing retards trying to ACK-CHUALLY back at me. Naturally, they're failing at it and therefore get to bask in my sharting and pissing all over them.
>>
>>107135808
It all started from this
>>107133517
This statement is correct. A pointer *is* a variable that holds a memory address on pretty much every sane architecture, including PDP-11. It doesn't imply that every variable that holds a memory address is of a C pointer type.
>>
>>107135808
You might have a point with the "just".



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.