How to answer what does safety mean to you

how to answer what does safety mean to you

A pointer to void is a "generic" pointer type. A void * can be converted to any other pointer type without an explicit cast. You cannot dereference a void * or do pointer arithmetic with it; you must convert it to a pointer to a complete data type first.. void * is often used in places where you need to be able to work with different pointer types in the same code. For a more accurate definition of what pointers store, and how memory and addresses relate, see "More about memory addresses, and why you probably don't need to know" at the end of this answer. When you want to access the data/value in the memory that the pointer points to - the contents of the address with that numerical index - then you.

Join Stack Overflow to learn, share knowledge, and build your career. Connect and share knowledge within a single location that is structured and easy to search. It's usually good enough - unless you're programming assembly - to envisage a pointer containing a numeric memory address, with 1 referring to the second byte in zafety process's memory, 2 the third, 3 the fourth and so on For example, if the string literal happened to be at address 0x and p a bit pointer at 0x, the memory content would be:.

To refer to the characters p points to, we dereference p using one of these notations again, for C :. To use a pointer, a computer program also needs some insight into the type of data that is being pointed at - if that data type needs more than one byte to represent, then the pointer normally points to maen lowest-numbered byte in the data.

Sometimes you don't know how much memory you'll need until your program is running and sees what data is thrown at it It is common practice to store the address in a pointer Often a pointer may be the only indication ajswer where some data or buffer exists in memory.

For example:. Further, when you assign 0NULL and nullptr to a pointer the bits in doed pointer are not necessarily all reset: odes pointer may not contain "0" at the hardware level, or refer to address 0 in your virtual address space. The compiler is allowed to store something else there if it has reason to, but whatever it does - if you come along and compare the pointer to 0NULLnullptr or another pointer that was assigned any how to answer what does safety mean to you those, the comparison must work as expected.

More what stores accept internet coupons, initialised pointers store a bit-pattern identifying either NULL or a often virtual memory address. Specific OS functions, e.

Attempts to move legal pointers beyond these boundaries, or to cast arbitrary numbers to pointers, or use pointers cast to unrelated types, typically have undefined behaviourso should be avoided in answee level libraries and applications, but code for OSes, device drivers, answerr. Dereferencing a pointer means getting the value that is stored in the memory location pointed by the pointer.

A pointer is a "reference" to a value. If the book isn't there, the librarian starts shouting, how to answer what does safety mean to you the library down, and a couple of people are set to investigate the cause of a person abswer to find a book that isn't there.

In simple words, dereferencing means accessing the value from a certain memory location against which that pointer is pointing. Code and explanation from Pointer Basics :. The dereference operation starts at the pointer and follows its qhat over to access its pointee.

The goal may be to look at the pointee state or to change the pointee state. The dereference operation on a pointer only works if the pointer has a pointee -- the pointee must be allocated and the pointer must be set to point to it. The most common error in pointer code is forgetting to set up the pointee. The most common runtime crash because of that error in the code is a failed dereference operation. In Java the incorrect dereference will be flagged politely by the runtime system. Pointer bugs in compiled languages can be difficult to track down for this reason.

I think all the previous answers are wrong, as they state that dereferencing means accessing the actual value. It operates on a pointer variable, and returns an l-value equivalent to the value at the pointer address. This is called "dereferencing" the pointer. That said, we can dereference the pointer without ever accessing the value it points to.

Again, dereferencing, but never accessing the value. Such code will NOT crash: The crash happens when you actually access the data by an invalid pointer. However, unfortunately, according the the standard, dereferencing an invalid pointer is an undefined behaviour with a few exceptionseven if you don't try roes touch the actual data.

So in short: dereferencing the pointer means applying the dereference operator to it. That operator just returns an l-value for your future use. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Wha a free Team What is Teams? Learn more. Ask Question. Asked 10 years, 2 months ago. Active 10 months ago. Viewed k times. Please include an example with the explanation. Improve this question.

Rakete Binky's Pointer Fun cslibrary. There are so many goodies there Harry's response is the opposite of helpful here. Show 2 more comments. Active Oldest Votes. Reviewing the basic terminology It's usually good enough - unless whay programming assembly - to envisage a pointer containing a numeric memory address, with 1 referring to the second byte in the process's memory, 2 the third, 3 the fourth and so on What happened to 0 and the first byte?

Well, we'll get to that later - see null pointers below. For a more accurate definition of what pointers store, and how memory and addresses relate, see "More about memory addresses, and why you probably don't need to know" at the end of this answer. A pointer scenario Consider in C, given a pointer such as p below Losing and leaking addresses Often a pointer how to close an msn email account be the only indication of where some data or buffer exists in memory.

More about memory addresses, and why you probably don't need to know More strictly, initialised pointers store a bit-pattern identifying either NULL or a often virtual memory address. Improve this answer. Pacerier: from 6. Honey: the value hex is too big to encode in a single byte 8 bits of memory: you can only store unsigned numbers from 0 to in one byte. So, you just can't store hex at "just" the address Instead, a bit system would use 32 bits - which is four bytes - with addresses from to A bit system would use 64 bits - 8 bytes - from to what bank did wachovia buyout Either way, the base address of p is just if you had another pointer to p it would have to store in its four or eight bytes.

Hope that helps! TonyDelroy: If a union whwt contains an array arrboth gcc and clang will recognize that the lvalue u. I'm not sure whether the authors of those compilers think that the latter invokes UB, or that the former invokes UB but they should process it usefully anyway, but they clearly view the two expressions as different.

TonyDelroy: What's needed for safety and optimization isn't so much a "bit cast" operator, but rather a "restricted pointer" type which during its lifetime requires that all parts of an object that are accessed using a restricted pointer be accessed exclusively through it, and whose constructor could take a pointer of any type and cause accesses made through the restricted pointer to be treated as accesses to how to draw popular cartoons original type.

Most code that needs to use type punning what is a trayapp disk be amenable to such a construct, and it would allow many useful optimizations that would go beyond TBAA. Show 15 more comments. So, dereferencing gives this value. This is an indirect way to access a. Migol 7, 8 8 gold badges 44 44 silver badges 68 68 bronze badges.

Mahesh Mahesh A pointer doesn't point to a valueit points to an object. KeithThompson A pointer does not point to an object, it points to a memory address, where an object maybe a primitive is located. A pointer value is an address. An object, by definition, is a "region of data storage in the execution environment, the contents of which can represent values".

And fo do you mean by "primitive"? The C standard doesn't use that term. KeithThompson I was barely pointing out, that you did not actually add value to the answer, you were only nitpicking on terminology and did that wrong also. The pointer value surely is an address, that's how it "points" to a memory address. Show 7 more comments. Add a comment. Peter Mortensen 28k 21 21 gold badges 94 94 silver badges bronze badges. Fahad Naeem Fahad Naeem 6 6 silver badges 14 14 bronze badges. Code and explanation from Pointer Basics : The dereference operation starts at the pointer and follows its arrow ,ean to access its pointee.

You actually have to allocate memory for where x is supposed to point at. Your example has undefined behavior. Have you tried? I did. M Jul 3 '18 at Show 6 more comments. The Overflow Blog. Podcast One in four visitors to Stack Overflow copies code.

Podcast Non-fungible Talking. Featured on Meta. Stack Overflow for Teams is now free for up to 50 users, forever.

Reviewing the basic terminology

Cultural safety must not be allowed to drift away because it is too hard or too confronting. There is a paucity of literature on this area, and if nothing else practitioners and clients must be urged to contribute to the debate. ‘Cultural Safety - What does it mean for our work practice? What does 'wet clutch' mean when discussing power sports equipment? Answer: Wet clutches are immersed in motor oil in order to cool the clutch plates. They are often found in motorcycle applications, and they require fluids with certain frictional requirements to promote smooth shifting and .

Join Stack Overflow to learn, share knowledge, and build your career. Connect and share knowledge within a single location that is structured and easy to search. A pointer to void is a "generic" pointer type. One commonly cited example is the library function qsort :. It gets called like so:. There's nothing to protect you from using the wrong comparison routine:.

There's no way to catch this problem at compile time; you'll just wind up with a missorted array. For example, in socket functions, you have. C is remarkable in this regard. Rene has pointed it out. What there is how to "interpret" is left to the user. It's the only way to have opaque types in C. Very prominent examples can be found e.

It's treated very detailed in "C Interfaces and implementations". I suggest you read the complete chapter and try to understand the concept of a pointer to "get it". You can use, for example, if you want to pass an argument to function and this argument can be of several types and in function you will handle each type.

The void type of pointer is a special type of pointer. This allows void pointers to point to any data type, from an integer value or a float to a string of characters. But in exchange they have a great limitation: the data pointed by them cannot be directly dereferenced which is logical, since we have no type to dereference to , and for that reason we will always have to cast the address in the void pointer to some other pointer type that points to a concrete data type before dereferencing it.

A void pointer is known as generic pointer. I would like to explain with a sample pthread scenario. The pthread API designers considered the argument and return values of thread function. A pointer to void may be converted to or from a pointer to any object type. A pointer to any object type may be converted to a pointer to void and back again; the result shall compare equal to the original pointer.

You can use this generic pointer to store a pointer to any object type, but you can't use usual arithmetic operations with it and you can't deference it. When you pass a void pointer to a function you will need to know what its type was in order to cast it back to that correct type later in the function to use it. You will see examples in pthreads that use functions with exactly the prototype in your example that are used as the thread function.

You need to be careful when using void pointers though as unless you case back to a pointer of its true type you can end up with all sorts of problems. Stack Overflow for Teams — Collaborate and share knowledge with a private group.

Create a free Team What is Teams? Learn more. Ask Question. Asked 8 years, 9 months ago. Active 1 year, 1 month ago. Viewed k times. In addition, when do we need to use this kind of pointer and how to use it? Improve this question.

Robert Harvey k 43 43 gold badges silver badges bronze badges. OneZero OneZero What C book are you using? You're asking for the better part of an entire chapter. Have a look at stackoverflow. Its answered before: stackoverflow. Take a cue from malloc and calloc. The man page goes on to say: " Add a comment. Active Oldest Votes. It gets called like so: int iArr[10]; double dArr[30]; long lArr[50]; Improve this answer. John Bode John Bode k 16 16 gold badges silver badges bronze badges. But for data pointers what you said holds.

But void is better as it cannot actually be used to alter anything directly. TheSteve TheSteve 1, 6 6 silver badges 12 12 bronze badges. So that's pretty much like generics in other languages, but with no type checking, right? I suppose it would be similar, however since there is no type checking, making a mistake can cause very strange results or cause the program to outright crash. Chris Tang 7 7 silver badges 14 14 bronze badges. Friedrich Friedrich 5, 23 23 silver badges 41 41 bronze badges.

This also works for C language. Jeyaram Jeyaram 8, 5 5 gold badges 35 35 silver badges 59 59 bronze badges. Seabass77 Please refer stackoverflow. The function takes a pointer to an arbitrary type and returns one such. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown.

The Overflow Blog. Podcast One in four visitors to Stack Overflow copies code. Podcast Non-fungible Talking. Featured on Meta.

Stack Overflow for Teams is now free for up to 50 users, forever. New onboarding for review queues. Should the [complete] tag be removed? Outdated Answers: results from use-case survey. Downvotes Survey results. Linked 6. See more linked questions. Related Hot Network Questions.

Question feed. Stack Overflow works best with JavaScript enabled. Accept all cookies Customize settings.

How to answer what does safety mean to you: 1 comments

Add a comment

Your email will not be published. Required fields are marked *