Thread: "The Devil function"

  1. #16
    Join Date
    Oct 2007
    Inside my computer
    I'll fill you in a little further:
    Virtual memory, the memory a process uses to read and write to, is divided into blocks the size of a byte. To be able to use all the memory, each block needs an address. A virtual address. Now, when you pass something to a function, usually it's by value - a new variable is created and the original value is copied to the new variable.
    But if you want to change the original variable you pass into a function, then you must tell that function the address of the original variable, otherwise it can't find it. And to get the address of a variable, you must use the address of operator (&). If you do not use this, then you are lying to the function and supplying an invalid address, thus causing the whole thing to fall apart.
    Note that arrays are an exception to the address rule. Instead of copying the entire array by value, the compiler instead takes the address where the array begins by default, thus creating a pointer without the need for &.

    So when a function takes a pointer, pass the address of the variable instead of its value. Or pay attention to warnings or use C++ to compile your code since it will result in a compile error.
    Last edited by Elysia; 04-01-2008 at 09:53 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Check out DEVIL Screensaver System!
    By hartwork in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 08-31-2005, 06:28 PM
  2. "The Messenger Service"
    By sean in forum A Brief History of
    Replies: 15
    Last Post: 07-08-2003, 10:18 PM
  3. "The Simpsons"
    By CompWiz84 in forum A Brief History of
    Replies: 20
    Last Post: 07-05-2002, 06:27 AM
  4. "The C++ Programming Language"
    By d00b in forum C++ Programming
    Replies: 6
    Last Post: 06-14-2002, 12:17 AM