what the FUCK is a pointer
What the FUCK is a pointer
Other urls found in this thread:
fresh2refresh.com
dev.mysql.com
twitter.com
assign directly to a memory address.
why? faster processing
Dumb frogposter.
t. boomer
A pointer is a reference to something in memory using it's memory address
it references a spot in memory, which lets you do things like have another function modify a variable in the caller
there are other uses (and references make that particular usage of pointers archaic), but I can't be arsed to go into 'em
Pointers don't exist. They are just unsigned integers.
false, the concept is hard-wired in CPU
A boomer term for a remote control, typically for a television. Another common term is "clicker."
so this is the latest cool insult?
It points to a memory address that holds a value
eg.
char string[] = “hello world”
char* ptr = string;
Both string and ptr are variables. A string literal,”hello world “ occupies a space in memory and then string, which is located at a different memory address, points to it.
Then ptr is at another memory address and pointing at string.
Actually not really. Some opcodes simply depend on the contents of the memory register - concept of variables itself doesn't exist on that level, let alone types of variables.
> Both string and ptr are variables
I mean they are both pointers
wrong game
my apologies
Reference to a memory address
It's a variable that holds a memory address to the type, eg, int * is a pointer to int, int ** is a pointer to pointer to int.
It's no different from an integer, you use the indirection operator * to access what's at the memory address rather than the value of the variable itself.
But this game has a 20 years old boomer.
It's a useless way of overcomplicating simple things.
Make a linked list without pointers.
All space inside your memory has an address associated with it like we have with house numbers. You can also store this address inside memory to refer to it later.
Consider your memory a massive array. You would access all possible addresses by simply using the [] operator like array[5]. In this context this would literally mean your address(pointer) is 0x00000005 for example. You can also store these addresses to refer to them later. Arrays are pointers with an offset value given to them to get the variable.
int variable = 5;
int *addressToVariable = &variable;
int variableFromAddress = *addressToVariable;
addressToVariable(pointer of var operator & and pointer of type int*) now contains the address to the variable called variable. variableFromAddress contains the number 5(dereference operator *).
The confusing part is using & and * that can mean different things in different contexts. If you put a & in front of a variable you'll get the pointer. If you put * in front of a pointer you'll get the variable. However * is also used to declare a pointer as seen on the second line. It's just something you'll have to get comfortable with.
It's not. Pointers are implementation specific but usually use the native integers of the processor to store them, same as any other variable. CPU's have no concept of variables and pointers. Everything is just a n bit binary number.
Give me 3 uses for a linked list.
I asked first.
segmentation fault
core dumped
>im sharing board with this person
I'd use object references.
Simplest explanation coming through
Pretend your ram is an array. A pointer is an index to something in that array.
You didn't ask anything, I assume the confusion caused by having too many pointers up in your head.
>I am posting on the same subreddit as a retard who thinks pointers are not garbage
what is an index
what is an array
So what are you going to store in the last element's "next" reference?
>You didn't ask anything
Lack of reading comprehension, as expected from someone who can't comprehend pointers.
An index is a penis
An array is a vagina
>Make a linked list without pointers.
Nice question faggot.
Teleport to the right address.
>>I am posting on the same subreddit as a retard who thinks pointers are not garbage
>he still hasnt stopped posting dumb shit
maybe you dont understand that C is meant to be just one step above assembly (portable assembly basically)? how do you think "references" work on the machine code level?
if you want higher level, then C isnt the language you are supposed to use - it has different uses
thats like saying an ordinary screwdriver is a useless garbage tool because we have battery-powered screwdrivers
you
dumb
fuck
Do you think only questions can be asked? Are you legit retarded?
>Are you legit retarded?
likely
either a pajeet or a jav*scripter
If you don't specify the specific type of ask, I assume you're referring to a question by default.
You can do whatever you want in C99 without using pointers.
n
o
u
Eat my feces, I bet I can write a program faster than you using only 7 fingers.
>pic related
>You can do whatever you want in C99 without using pointers.
now i know for sure you have never ever written anything in C beyond hello world tier
the absolute state of Jow Forums
>If you don't specify the specific type of ask, I assume you're referring to a question by default.
Oh, legit retarded then, my condolences..
class LiLi{
push(object){
let i = this.head;
if(!i) return this.head = {o: object, n: null};
else while(i.n) i = i.n;
i.n = {o: object, n : null}
}
}
Q.E.D.
t. js webdev
When you talked about references I assumed C++, where references can't be null, but eh, fair enough. That's also how it's done in languages without raw pointers.
I am a freelancer, mostly working with Perl and MySql to build retail systems.
You can't expect me to understand that you're actually asking me to do something when giving me an order on a forum.
I have written a program in C that stores given Perl snippets in a MySql database and can string multiple snippets together so I can get a base to build programs up on. I didn't use any pointers btw.
is that your only complaint?
make a proxy object that acts as a null reference (aka tail) and add a private state field that checks whether (or where) the tail reference is
what are you, a babby?
abstraction level : 0
>You can't expect me to understand
Well, that's a consequence of being retarded, so yeah.
That's pretty wasteful memory-wise, maybe some trickery with unions could optimize it.
Fairly sure this is 100% accurate:
>a variable that holds a memory address.
this is quite a good example. char *ptr now points to the first char in string[], or; &string[0]. Since an array is just consecutive memory you can iterate the memory, this is kind of how printf works behind the scenes.
while (*ptr++ != 0) //aka '\0'
putchar((int)*ptr))
good doge
adding one private integer field to register where the tail is takes exactly
char : 1 byte
short : 2 bytes
int : 4 bytes
long : 8 bytes
you are indeed the dude whom the other dude is complaining about - about shifting the goalposts - aren't you.
what are we developing for, a 1989 gameboy cartridge?
fucking based
>takes exactly
Exactly - it takes memory for no reason. Could be solved by making a union of list element and a bool, emulating a null basically, since any valid list element would result in "true" value for the boolean.
>pointers
>complicated
or you could use whatever tool enables the efficient development within the given parameters (which may or may not include pointers) and stop backpeddaling from the actual issue:
issue: Make a linked list without pointers.
solution:
your non functional change request was denied by the architect. have a good day.
who the fuck cares about O(1) in a datastructure? are you a retard?
im 99% sure that SQL interface uses pointers
>O(something) issue
>this
>pointers
>useful
>and stop backpeddaling from the actual issue
I already said it's a fine solution, just not the best.
>he is still posting
an SQL interface for a DB uses SQL, FYI
maybe go back to school? :/
Well, when you're writing your 53rd iteration of Hello World they might not be. However, we're not talking about code that would make a pajeet laugh here.
how did you connect to that database in C without using pointers you dumb fuck?
dev.mysql.com
maybe kill yourself? :/
fuck you fight me irl 1v1
Now I know you are making shit up. To interface with MySQL in C, you need to use C, not just SQL.
What have you ever written in C that couldn't be done without pointers?
Imma make the final solution for your sorry ass.
i'll expect your chutsbe before yom kippur
how do you pass large structures to functions without killing performance by copying everything? how do you pass buffers of variable length to functions? how do you pass strings to functions? how do you make functions which modify some of their input argument?
protip: learn C first before debating on the topic of C and pointers
There's a simple answer but you won't like it - global variables.
>Lists
>Trees
>Dynamic memory allocation
>Accessing GPU memory
>Virtual method tables
>Run time linking of dynamic libraries
There's just a few cases where pointers are useful.
who the fuck writes c?
why the fuck don't yall niggers move the goalposts all the way down to machine language?
Try opening a file
>What do you even need pointers for in C?
>You need it for x, y, z, etc...
>lmao who the fuck even uses C?
Here's one for your efforts, buddy.
Global variable containing path.
how will you use that if you want to use library functions in multithreaded program while accessing other threads' data?
global variables literally dont cover all cases, so your answer is incorrect
programmers are speaking, begone
that would still be a pointer, dumbo, as it is a string
Graphics programming
>global variables literally dont cover all cases
Never said they do. They cover what you asked about.
>how do you pass buffers of variable length to functions?
it doesnt cover this one
>how do you pass buffers of variable length to functions?
realize maybe that you were being baited, sweet summerchild? look at the post, and think for a second.
>programmers are speaking, begone
lel
>that would still be a pointer, dumbo, as it is a string
Now you're moving the goalposts, again, for the hundredth time. Pointerfags stop.
im not, you just got proven false
No shit, hence the point of the image and the sardonic reply.
Huge global array and the length value. Maybe an offset as well if you need multiple buffers.
Linking a DLL at run-time
you just got baited again, user
just give them (You) and ignore
thats not a buffer of variable length, thats a buffer of fixed length
furthermore, it would be immensely impractical - imagine im programming a graphical editor, am i gonna make a 2GB statically allocated buffer even tho a user might just need 1MB?
And you think pointers are an overcomplication? Hilarious.
False is a boolean just like true, so you've proven me right. Eat my ass and call me Nicholas.
You don't need any pointers for that.
Hey fuckface, I'm still waiting for a (You)
why would you want to reference the value's address rather than the value itself