Factbites
 Where results make sense
About us   |   Why use us?   |   Reviews   |   PR   |   Contact us  

Topic: Pointer arithmetic


  
  Data pointer - Wikipedia, the free encyclopedia
Null pointers are used routinely, particularly in C and C++, to represent exceptional conditions such as the lack of a successor to the last element of a linked list, while maintaining a consistent structure for the list nodes.
Pointer arithmetic, that is, the ability to modify a pointer's target address with arithmetic operations, is unrestricted: adding or subtracting from a pointer moves it by a multiple of the size of the datatype it points to.
Pointer arithmetic is unrestricted; adding or subtracting from a pointer moves it by that number of bytes in either direction, but using the Inc or Dec standard procedures on it moves it by the size of the datatype it is declared to point to.
en.wikipedia.org /wiki/Pointer   (3014 words)

  
 Dangling pointer - Wikipedia, the free encyclopedia
Dangling pointers (also known as wild pointers) in programming are pointers which do not point to a valid object of the appropriate type, or to a distinguished null pointer value in languages which support this.
The pointer still points to the location in memory where the object or data was, even though the object or data has since been deleted and the memory may now be used for other purposes, creating a dangling pointer.
As a result of inappropriate pointer casts (which may cause the pointer type to not match the type of the object, in typed languages) or inappropriate pointer arithmetic.
en.wikipedia.org /wiki/Wild_pointer   (962 words)

  
 Pointer Arithmetic   (Site not responding. Last check: 2007-10-22)
Arbitrary pointer casting allows you to access any memory location and do anything you want at that location, regardless of whether you can access that memory location or whether the data is valid at that memory location.
Pointer subtraction isn't used very much, but can be handy to determine the distances between two array elements (i.e., the difference in the array indexes).
It's said that a good programmer understands pointers very well, while an average programmer finds anything with more than one pointer difficult to manage (e.g., a pointer to a pointer to an int is seen as difficult).
www.cs.umd.edu /class/spring2003/cmsc311/Notes/BitOp/pointer.html   (2042 words)

  
 Project 1
In fact, pointers and arrays are very related in C (and thus in C++).
When it sees ptr + i, it translates this (internally) to addr(ptr) + (i * sizeof(type)) where type is the type of the dereferenced pointer and addr is a "function" that returns the address of the pointer (of course, the pointer is actually an address, so this function doesn't do much but return that address).
Pointer arithmetic is usually covered in a book on C. For example, it is covered in the CMSC 106 textbook.
www.cs.umd.edu /class/fall2002/cmsc214/Tutorial/pointer.html   (601 words)

  
 C programming language
Pointers can be freely manipulated, using normal assignments and also pointer arithmetic.
The run-time representation of a pointer value is typically a raw memory address, but at compile time, a pointer variable's type includes the type of the data pointed to, which allows expressions including pointers to be type-checked.
Although properly-used pointers point to safe places, they can be moved to unsafe places using pointer arithmetic; the memory they point to may be deallocated and reused (dangling pointers); they may be uninitialized (wild pointers); or they may be directly assigned a value using a cast, union, or through another corrupt pointer.
www.brainyencyclopedia.com /encyclopedia/c/c_/c_programming_language.html   (6023 words)

  
 SparkNotes: What Are Pointers?: Pointers and Arrays
Pointers and arrays are not exactly the same entity, but they're very close.
So all a pointer really holds is a big number, say, for example, 0x4b14 (or in binary 0b0100101100010100).
We use pointer arithmetic to move us to the nth place in the array, and then dereference it to get the integer at that index.
www.sparknotes.com /cs/pointers/whatarepointers/section3.rhtml   (1203 words)

  
 What is a Pointer?
Pointers, as explained, contain a numerical value, which is a particular address in memory.
Pointer arithmetic done to this pointer will be relative to where that pointer points.
that is referenced by the pointer to pointer to
thelinuxlink.net /~fingolfin/pointer-guide   (4777 words)

  
 wksht4
Pointer arithmetic automatically adjusts for the size of the data type that a pointer points to.
Note that when a pointer is passed as an argument to a function, the function does not know how much memory the pointer is pointing to (if any).
The third version should use a second pointer which is initialized to the start of the string, and this pointer should be incremented.
www.cs.rpi.edu /~lallip/cs2/wksht4/wksht4.html   (1791 words)

  
 3. Pointers - Part 3   (Site not responding. Last check: 2007-10-22)
Strictly speaking, pointer arithmetic is undefined except for pointers pointing to the same array, either to an element within the array, or one element beyond the end.
Pointers cannot be added to each other, but pointers of the same type pointing to the same array (within or one element beyond) can be subtracted from each other, yielding an integral type
Pointers can be compared with each other, though as with arithmetic, results are undefined unless the two pointers each point either within or to one element beyond the same array.
www.pa.msu.edu /courses/1996spring/PHY405/lect3c.html   (1080 words)

  
 Hour 16 - Applying Pointers
In other words, adding 1 to (or subtracting 1 from) a pointer is not instructing the compiler to add (or subtract) one byte to the address, but to adjust the address so that it skips over one element of the type of the pointer.
Among them, ptr_ch is a pointer to a character, ptr_int is a pointer to an integer, and ptr_db is a pointer to a double.
Note that the pointer, ptr, is specified with the int data type and passed with a char pointer.
aelinik.free.fr /c/ch16.htm   (4706 words)

  
 Pointer arithmetic   (Site not responding. Last check: 2007-10-22)
A limited set of arithmetic operations may be performed on pointers.
An integer may be added to a pointer; an integer may be subtracted from a pointer; two pointers of the same type may be subtracted one from the other.
Pointers may also be compared for equality, and the order relations
www.cogs.susx.ac.uk /users/peterw/progtech/notes/html/node34.html   (161 words)

  
 Pointers   (Site not responding. Last check: 2007-10-22)
Arrays and pointers in C and C++ are semantically very similar, the only difference being that arrays have storage allocated at compile time and cannot be made to point anywhere else; this sub-section will explain the similarity.
The only difference between pointers and arrays is that the array name cannot be assigned to since it only functions as a constant pointer to its storage and no location for the pointer exists (unlike real pointers).
pointer of the current cell can be changed, and (iv) it is necessary to save a copy of the changed pointer so it can be deleted and returned to free storage.
homepages.feis.herts.ac.uk /~msc_fl/fl-node25.html   (2392 words)

  
 Pointer Arithmetic   (Site not responding. Last check: 2007-10-22)
Arithmetic can be performed on pointers just like any other variable, this is only useful in a few cases though.
If you were (for some reason) to divide a pointer by two it would then point to an area of your computers memory that would probably not belong to your program.
In the case of addition (and subtraction), arithmetic is performed in units equal to the size of the pointers data type.
www.faqs.org /docs/learnc/x652.html   (139 words)

  
 The MOST: EoC CHAPTER 5 - POINTERS
That is, pointers are incremented and decremented relative to the length of their base type.
Arithmetic operations are not limited to the increment and decrement operators.
Since any pointer may be indexed as if it were a single-dimension array, the pointer returned by the malloc() function may be indexed in the normal way.
www.themost.org /courses/langs/eoc/lessons/eoc_05.html   (747 words)

  
 C++ LECTURETTES - Pointer Arithmetic
In the previous section we saw that a pointer is a data object that stores the address of another data object.
We know that the array nametag is a pointer to the first element in the array, and that tha elements in the array are all integers.
It should also be noted that, if we add the value 1 to a pointer, it does not increase the value of the pointer to the address of the next byte of memory.
www.infocom.cqu.edu.au /Staff/Mike_Turnbull/Home_Page/Lecturetts/sect203.htm   (1732 words)

  
 Pointer arithmetic - GIDForums
Oh yeah, I have to use pointer arithmetic (not array subscripting) to visit the array elements.
You want to pass the address of matrix to the function (this a pointer to an int, since matrix is a (two-dimensional) array of int).
also to do pointer arithmetic, just assign a pointer to the first element of your array and or your array itself just keep incrementing it till you reach the end.
www.gidforums.com /t-2280.html   (1095 words)

  
 Objects First: Pointer Arithmetic   (Site not responding. Last check: 2007-10-22)
As noted earlier in the introduction to pointers, pointers are a difficult concept in C. Some of this difficulty is created by C programmers who make extensive use of C's pointer arithmetic capabilities.
In the second case, we use the fact that the name of an array is a pointer to its first element and use pointer arithmetic to advance the pointer to the address
Arithmetic on pointers to objects which are not characters obeys a special rule.
www.oopweb.com /CPP/Documents/ObjectsFirst/Volume/pointer_arith.html   (984 words)

  
 Pointer Arithmetic
In those situations that you can use a pointer, you can perform operations on the pointer value to index through memory.
Therefore, using pointers to address data types smaller than 32 bits is more difficult: each increment of the pointer must be 4 bytes, and the data must appear in the same place in every 4 byte word.
One possible way to use pointers involves declaring a pointer type based on a register.
www.bytecraft.com /tutorials/public/etpuc/ch05s01.html   (496 words)

  
 The Beginner's Guide to Pointers in C - The Dark Box
Well, we have to specify it as a pointer when we create it by using an asterisk, which tells C, "This is not a variable of this type; it's a pointer to a variable of this type".
When you create a pointer of a certain type and assign it the address of a variable, that pointer is not necessarily tied to that variable.
Pointers are an extremely tricky subject and require a fair bit of practice.
darkbox.pentagod.com /pointers.htm   (2152 words)

  
 Chistory
Within procedures, the language's interpretation of the pointers was identical to that of the array variables: a pointer declaration created a cell differing from an array declaration only in that the programmer was expected to assign a referent, instead of letting the compiler allocate the space and initialize the cell.
declare an integer, a pointer to an integer, a pointer to a pointer to an integer.
Pointers, for example, were barely distinguished from integral memory indices in early language manuals or extant code; the similarity of the arithmetic properties of character pointers and unsigned integers made it hard to resist the temptation to identify them.
www.cs.bell-labs.com /cm/cs/who/dmr/chist.html   (8388 words)

  
 Expressions
For example, an integer constant expression is a subset of all arithmetic constant expressions, which in turn is a subset of all rvalue expressions.
Each of the operands is converted to the balanced type, the arithmetic operation occurs between the now identical types, and the result of the operation has the balanced type.
If you then convert that pointer to a type compatible with the original pointer, it will equal the original pointer and you can use the pointer to access the object.
www.siue.edu /~jweinbe/STD_C/express.html   (6374 words)

  
 Christian Nagel's OneNotes : C++/CLI: Pointer Arithmetic with Embedded Value Types   (Site not responding. Last check: 2007-10-22)
With C++/CLI it is possible to use the interior_ptr<> keyword for using pointer arithmetic with value types that are embedded in a managed class.
Now it would be interesting to iterate through all the elements in the array by using a pointer that references the first element, a pointer that points after the last element, and to use pointer arithmetic to step through all ements:
A native pointer cannot be aware of this fact.
weblogs.asp.net /cnagel/archive/2005/03/15/394638.aspx   (258 words)

  
 Pointer Arithmetic (C/C++ Language and C++ Libraries)   (Site not responding. Last check: 2007-10-22)
Additive operations involving a pointer and an integer give meaningful results only if the pointer operand addresses an array member and the integer value produces an offset within the bounds of the same array.
When the integer value is converted to an address offset, the compiler assumes that only memory positions of the same size lie between the original address and the address plus the offset.
Similarly, when two pointer values are subtracted, the conversion assumes that only values of the same type, with no blanks, lie between the addresses given by the operands.
msdn.microsoft.com /library/en-us/vclang98/html/_clang_pointer_arithmetic.asp?frame=true   (188 words)

  
 Everything you need to know about pointers in C
Thus it is an ‘int pointer’ (a pointer to int).
This is not useful for anything, except to declare function pointers (described later).
When you add to or subtract from a pointer, the amount by which you do that is multiplied by the size of the type of the pointer.
geocities.com /iamtheboredzo/pointers   (2352 words)

  
 10.2 Pointers and Arrays; Pointer Arithmetic
Pointers do not have to point to single variables.
Given that we can add 1 to a pointer, it's not surprising that we can add and subtract other numbers as well.
When you're doing pointer arithmetic, you have to remember how big the array the pointer points into is, so that you don't ever point outside it.
www.eskimo.com /~scs/cclass/notes/sx10b.html   (481 words)

  
 12.3 Pointer Arithmetic   (Site not responding. Last check: 2007-10-22)
Thus, the assignment compatibility between pointer types and address types means that these function procedures can be applied to pointers and can return values to be assigned to pointers in expressions.
It is important to note that manipulating pointers in this fashion requires a thorough knowledge of the specific machine being used and particularly the manner in which it uses addresses and pointers.
This facility can also be useful when a particular machine is known to have certain specific memory set aside for special purposes, and it is desired to access that memory via pointers.
www.arjay.bc.ca /Modula-2/Text/Ch12/Ch12.3.html   (307 words)

  
 Pointer Arithmetic
All objects in C and all objects of PlainOldData types in C++ can be treated as arrays of bytes (unsigned char in C; either char or unsigned char in C++).
According to the C and C++ standards, pointer arithmetic is only valid within an array or just off the end of it - it is valid to point to "one past the end" of the array provided that such pointers are never dereferenced.
On most modern CPUs, pointers are harmless until dereferenced; but on some older machines the mere act of loading an invalid pointer into a register may cause a GeneralProtectionFault.
c2.com /cgi/wiki?PointerArithmetic   (692 words)

  
 How to do pointer arithmetic in Delphi.   (Site not responding. Last check: 2007-10-22)
When you are dealing with dynamic memory locations and all you have is a pointer to where it all begins, you want to have the ability to traverse that line of memory to be able to perform whatever functions you have in mind for that data.
This can be accomplished by changing the place in memory where the pointer points.
The main idea that must be kept in mind when doing your pointer arithmetic is that you must increment the pointer's value by the correct amount.
community.borland.com /article/0,1410,15926,00.html   (269 words)

  
 Fortran 90 Tutorial
Pointers are variables with the POINTER attribute; they are not a distinct data type (and so no 'pointer arithmetic' is possible).
They are conceptually a descriptor listing the attributes of the objects (targets) that the pointer may point to, and the address, if any, of a target.
The source code of an extended example of the use of pointers to support a data structure is in appxg.f90
wwwasdoc.web.cern.ch /wwwasdoc/WWW/f90/pointers.html   (773 words)

Try your search on: Qwika (all wikis)

Factbites
  About us   |   Why use us?   |   Reviews   |   Press   |   Contact us  
Copyright © 2005-2007 www.factbites.com Usage implies agreement with terms.