[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".
>>
>>107133306
I have no idea what it is but I'm going to take a wild guess that it takes an integer, cubes it, and sets it to a variable.
>>
>/g/ getting filtered by pointers
ngmi
>>
>>107135890
>a pointer IS what I want it to be
>except for when it isn't
>in which case the problem isn't my incorrect understanding
>it's just the computer being insane
Anon, please leave pointers alone and just use javascript or something.
>>
>>107133306
ive used ** once to avoid special casing while implementing sorting for an assignment but i have no idea when id need a ***
>>
>>107136155
You're a retard.

It's a variable that holds an address, generally a memory address, in all but one or two implementation defined niche cases from 50 years ago.

Go fuck yourself you pedantic autistic mongrel.
>>
>>107136202
Instead of being wrong and then getting absolutely assblasted when someone points it out, why not just say "on most architectures, the value of a pointer is just a memory address"? Then you wouldn't be misleading other people who, like you, don't know any better.
>>
>>107136237
Because I don't like you.
>>
>>107136243
Yes, but do you like being wrong about pointers?
>>
>>107136262
I'm not wrong in 99.9999~% of cases. I'm closer to right about this than anything i have been in my entire life.
>>
>>107136277
You are wrong in 100% of the cases when you are not right. That is more than zero cases in practice and an unbounded number of cases in theory. Your incidental correctness rate (and here I must emphasize the word 'incidental') theoretically approaches 0.
>>
>>107133986
https://grep.app/search?f.lang=C&q=int***
>>
>>107136356
I want to ride bikes up to the playground and fight you.
>>
>>107133517
It literally is on any platform that matters.
>>
File: file.png (201 KB, 1458x832)
201 KB
201 KB PNG
I wonder whats the highest indirection you can use.
>>
>>107136387
There's some dude that's hung up on the standard leaving the definition open because a Cambodian postage stamp printer that never went into production used pointers to store text strings in 1973 or whatever the fuck.
>>
>>107136384
>I want to ride bikes up to the playground and fight you.
I'd tell you the address of the closest playground but you'll probably confuse it for a pointer and end up who knows where.
>>
File: 1739159322410004.png (338 KB, 564x564)
338 KB
338 KB PNG
>>107136379
>
case NRUTIL_UPTR3:
v = (unsigned int ****) gvector(nl, nh, sizeof(unsigned int***)) -nl+NR_END;
break;
case NRUTIL_UPTR4:
v = (unsigned int *****) gvector(nl, nh, sizeof(unsigned int****)) -nl+NR_END;
break;
>>
>>107136410
I'd give YOU the address but you'd spend 7 hours trying to decide if was a place or if it was the one time in human history something that means an address under all other circumstances was actually a recipe for fried white fish.
>>
>>107136451
Or you could just give me a valid zip code so we could meet up and amicably discuss the merits of non-Von-Neumann architectures.
>>
>>107136418
Holy fuck this code makes me queasy.
>>
Can somebody explain this to me?
I use pointers all the time, but I still have no fucking clue what they mean, and then when I reread what I wrote, I still have no clue what the fuck I wrote.
>>
My daily programming task involves investigating pointers.
I observe what they are, I have no clue what the fuck they do.
I rewrite the pointers, I have no clue what the fuck they do.
I test out the pointers, I have no clue what the fuck they did, but they didn't do what I wanted them to do.
I reread the pointers, I have no clue what the fuck they are doing.
I rewrite the pointers, I have no clue what the fuck I just did.
I test out the pointers, I have no clue what the fuck they did.
Sometimes I get stuck in-between one of these steps.

What do I call this action phenomenon?
>>
>>107136576
I'd tell you what most people would tell you, but a guy itt will either beat me up or make me learn about neural network computing architecture.
>>
File: 71bEFrADiUL.jpg (254 KB, 1979x2560)
254 KB
254 KB JPG
>>107136576
Read the section about pointers from picrel book
This should be mandatory reading for anyone posting on /g/.
>>
>>107135596
tech isn't worth dealing with all of you autists. im glad the entire industry is being outsourced to mumbai
>>
>>107136403
i've spammed it to 166, gcc didn't flinch. the limit must be something stupid.
>>
>>107136576
>Can somebody explain this to me?
3 stars => 3 hoops to jump through before you get your smelly int. Simple as.
>>
>>107136576
a pointer is a just a data type like an integer or float. on 64 bit machines it is always 8 bytes. a pointer stores the value of a memory address as an integer. this is usually done with the semantic"int* ptr = &val". you can also assign a pointer to a special value "null" which is actually just the memory address 0. you can access the contents of the memory address with the dereference operator, "int i = *ptr". this means i is equal to whatever value is stored at memory address ptr. in op's example int*** means a pointer to a pointer to a pointer. this could be a pointer to a 2d array, or just an integer.
>>
>>107133306
>what is this, and when might it be used?
garbage question form - you don't just start with an out-of-context solution and look for problems to apply it. that's not how you do problem solving, or programming.
what's even the point of such a question? what, as an interviewer, do you actually learn if you do get an answer? hell, what conclusions do you draw when you don't get an answer, other than "ha! gotcha"?

this kind of questioning to be expected from larping NEETs or teachers that can't program (if they could, they would have become programmers and not teachers)
>>
>>107136576
First you have to understand the difference between heap allocation and stack allocation.
Pointers are not useful for anything allocated on the stack except if you want a function with side-effect.
Pointers are needed for heap allocations because those are dynamically made.
If you don't understand those differences, you will fail to understand why Java has no pointers.
The answer is that in Java, everything except primitive types are pointers so it is useless to specify that they are pointers. It is possible to allocate an object on the stack in C++ but it is not possible in Java.

MyObject myObject in C++ -> stack
MyObject myObject in Java -> heap
MyObject* myObject in C++ -> pointer (allocated on the stack) pointing toward a memory space allocated dynamically (heap)
>>
>>107136701
here is an example visually.
int main()
{
int i = 10;
int* p1 = &i;
int** p2 = &p1;
int*** p3 = &p2;
printf("%p %p\n", p3, *p3);
printf("%p %p\n", p2, *p2);
printf("%p %d\n", p1, *p1);
return 0;
}

>>
>>107136757
>what's even the point of such a question?
Maybe to see if the interviewee has ever done anything more complex than fizzbuzz. A real programmer should be able to handle 5 levels of indirection at a minimum, like a dependency graph between modules of indirectly threaded functions. :^)
>>
>>107136757
Had to interview with an older guy who only asked me these questions. Piece of shit kept rephrasing the same questions wanting me to read his mind.
>>
>>107133306
>what is this, and when might it be used?

a mistake, obviously.
>>
>>107135066
then you should be using float
>>
>>107135241
If you want to jerk off to abstractions go program in Haskell you pretentious faggot.
A pointer is just a memory address, yes. That's what we've been saying all this time.
Now go dilate.
>>
>>107136155
Yes, it IS mostly a case of "the computer" (or more precisely the language designers) being insane. Nobody remembers the obscure details from the C standard that make things like casting a pointer to a suitably large scalar type and back undefined behavior for reasons like accommodating some obscure architecture from the 60s or saving 0.00001% runtime in some obscure corner case.
>>
>>107136237
Because nobody gives a shit about about your C to brainfuck compiler where pointers aren't memory addresses. The C language designers and users should pretend these don't exist rather than try to accommodate them.
>>
>>107136816
>Maybe to see if the interviewee has ever done anything more complex than fizzbuzz
OP's question fails even at that
there's probably a million better ways to evaluate that

>>107136842
that sounds unfortunate
>>
>>107136766
>First you have to understand the difference between heap allocation and stack allocation.
Does this actually matter in the year of our flying spaghetti monster 5786?
Python and JavaScript allocate literally every fucking thing as an Object() on the heap and even if a literal is stack allocated temporarily doing anything with it will dump it on the heap.
>>
File: 1731573580434798.png (32 KB, 460x307)
32 KB
32 KB PNG
You use pajeet tech, you get pajeet applicants.
>>
>>107136949
>>107137014
>>107137054
>gets filtered by one of the most basic abstractions in programming
>seethes like mad
Good.
>>
>>107137092
>OP's question fails even at that
According to OP it works just fine. Based on your posts, it would work even better than expected and exclude runts like you as well who get intimidated by a little asterisk if it appears more than once in a row.
>>
>>107133306
I've used a triple pointer once. I had a function that needed to output an array of strings. But I needed the return value for something else. So instead the char** is passed by pointer so it can be set by the function, which means passing a char***.

Can't say I've ever needed an int***, but the same idea applies. We're outputting a 2D array of ints but we need the return value for a status code or something.
>>
>>107133306
>triple indirection
it's a sign that you're a mediocre, probably an intern-level engineer that loves unnecessary complexity. unless you're constrained with shitty/extremely legacy third party apis, there's no legitimate reason to be playing around with triple indirection. we literally learned about triple indirection in our freshman year of university, and I wasn't even a CS major. you're not special for knowing about it.



[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.