[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

>pick up a language to learn and understand >read up on

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 20
Thread images: 1

File: 1495073868319.png (113KB, 507x743px) Image search: [Google]
1495073868319.png
113KB, 507x743px
>pick up a language to learn and understand
>read up on various algorithms, implement them
>fizzbuzz and calculator and shieet
>everything up to pointers is just fine and dandy
>pointers
>close the book and watch anime
>repeat above steps a month later
Why the fuck are pointers so damn confusing ? Are my pajeet genes acting up or something ? Should I pick up webdev ?
>>
>>60898267
the program memory is like a tape
every cell in the tape has an offset counted from the beginning
pointers store these offsets
so you can have a cell that stores "5" and if you have a pointer to that cell it merely stores the offset where that cell can be found
they're useful if you don't want to copy over entire structs that you take as function arguments, for example
>>
>>60898340
That would be the textbook definition. Why should I use them, instead of , references ? Are pointers and references same thing ? Are they merely there to confuse people
>>
>>60898374
Use pointers for when you can't move the object itself (too large, too complex), so you decide to move his address instead.
>>
>>60898374
>Are pointers and references same thing ?
yes, under the hood they are the same

void function(int *x);

allows you to do x = &somethingelse; and to access the actual value of the pointer (the cell offset) instead of the value of the cell the pointer points to
void function(int& x);

doesn't let you read / modify underlying cell value of the pointer; every time you use it, it is implicitly dereferenced (so you get the value of the cell that it points to)
>>
>>60898419
>>60898441
Thanks, I think I get it. It'd be really awesome if you could give me an example where there's a need for using pointers, in a video game context.
>>
>>60898488
You have a data structure that represent your pg, you can't reference it to make operations on it, you'll end to modify a mere copy. You use instead it's address that's only a number.
Warning, using the address means that you are modifing directly the variable, so be careful
>>
>>60898488
Try make a game, if you'll need pointers, you'll know. Keep avoiding them until possible
>>
>>60898560
>>60898534
Aha I get it. So is there ever a need to use pointers over references. I didn't get it wrong did I ?
In my understanding,
>reference:Address of something to operate on
>pointer:Variable that stores address of something to operate on
>>
>>60898603
Now, my C/C++ is somewhat rusty, but from what I remember References are constant aliases that do not exist in memory unlike pointers. Pointers are variables themselves that have an own address. This enables their primary feat, namely pointer arithmetic. You can address elements of an array for example by writing
char c = byte_arr_var+1;
Remember, that an array variable is a pointer to it's first element.
>>
>>60898267
Learn assembly and play with it on a RISC CPU and pointers will make a lot more sense.
>>
>>60899290
anon I can't seem to learn c++ properly, do you really think I'd learn assembly, then practise on RISC CPU , then learn C++ ?
You overestimate my abilities and time friend.
>>
>>60899353
C++ compiles into assembly, which then assembles into machine code. Pointers are low level memory addressing shit that you are not going to understand without actually directly playing with low level memory addressing shit.

You don't need to write a full application in assembly, or "practice", for that exploration to help you understand how pointers work.

The reason why I say you should use RISC, like an ARM box, like a Raspberry pi, is that you can write C code and use gcc -S and not have to decipher x86's instruction set.

Wake the fuck up, pajeet.
>>
>>60898603
Do you want to really learn?
To me there are two ways:
1) try ASSEMBLY, very low level and over time you'll learn
2) my favourite, learn FORTH, you'll understand memory in no time, and it's a fairly high level language (compared to assembly)
>>
>>60899513
I'm this guy again.
>>60899579
The point is that he needs to learn what CPU's are actually doing or else he's going to be a confused pleb forever.
>>
>>60899609
It's a long way to the top, you are right of course, but some help from programming language can't be bad
>>
>>60899609
I think I get your point anon, it's just that after wasting so much of my NEETlife never progressing, even the mention of another language seemed a timesink. I guess I'll give it a shot. Before I google stuff, do you have any resources to get me started, or books you'd recommend ?
>>
>>60899678
Forth helped me a lot, it's a eye opener
>>
>>60899688
This:
https://www.coursera.org/learn/digital-systems
Then this:
https://en.wikipedia.org/wiki/Modern_Operating_Systems

Don't poopsock it. Do small chunks and sleep on it so that you don't overload yourself and burn out. Learning things is like lifting weights.
>>
>>60899513
No pointers are indirections, and you can understand indirection without understanding low level addresses.
Thread posts: 20
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.